diff --git a/packages/schema/bind/src/bindings/assemblyscript/wasm-as/functions.ts b/packages/schema/bind/src/bindings/assemblyscript/wasm-as/functions.ts index 1591b78e61..deb619a6b7 100644 --- a/packages/schema/bind/src/bindings/assemblyscript/wasm-as/functions.ts +++ b/packages/schema/bind/src/bindings/assemblyscript/wasm-as/functions.ts @@ -20,7 +20,7 @@ export const toMsgPack: MustacheFn = () => { if (type[type.length - 1] === "!") { type = type.substring(0, type.length - 1); } else { - modifier = "Nullable"; + modifier = "Optional"; } if (type[0] === "[") { @@ -50,12 +50,12 @@ export const toWasmInit: MustacheFn = () => { type = type.substring(0, type.length - 1); } else { const nullType = toWasm()(value, render); - const nullable = "Option"; + const optional = "Option"; const nullOptional = "| null"; if (nullType.endsWith(nullOptional)) { return "null"; - } else if (nullType.startsWith(nullable)) { + } else if (nullType.startsWith(optional)) { type = nullType.substring(6); return `Option.None${type}()`; } @@ -112,19 +112,19 @@ export const toWasm: MustacheFn = () => { let type = render(value); let isEnum = false; - let nullable = false; + let optional = false; if (type[type.length - 1] === "!") { type = type.substring(0, type.length - 1); } else { - nullable = true; + optional = true; } if (type[0] === "[") { - return toWasmArray(type, nullable); + return toWasmArray(type, optional); } if (type.startsWith("Map<")) { - return toWasmMap(type, nullable); + return toWasmMap(type, optional); } switch (type) { @@ -177,11 +177,11 @@ export const toWasm: MustacheFn = () => { } } - return applyNullable(type, nullable, isEnum); + return applyOptional(type, optional, isEnum); }; }; -const toWasmArray = (type: string, nullable: boolean): string => { +const toWasmArray = (type: string, optional: boolean): string => { const result = type.match(/(\[)([[\]A-Za-z0-9_.!]+)(\])/); if (!result || result.length !== 4) { @@ -189,10 +189,10 @@ const toWasmArray = (type: string, nullable: boolean): string => { } const wasmType = toWasm()(result[2], (str) => str); - return applyNullable("Array<" + wasmType + ">", nullable, false); + return applyOptional("Array<" + wasmType + ">", optional, false); }; -const toWasmMap = (type: string, nullable: boolean): string => { +const toWasmMap = (type: string, optional: boolean): string => { const firstOpenBracketIdx = type.indexOf("<"); const lastCloseBracketIdx = type.lastIndexOf(">"); @@ -212,15 +212,15 @@ const toWasmMap = (type: string, nullable: boolean): string => { const keyType = toWasm()(keyValTypes[0], (str) => str); const valType = toWasm()(keyValTypes[1], (str) => str); - return applyNullable(`Map<${keyType}, ${valType}>`, nullable, false); + return applyOptional(`Map<${keyType}, ${valType}>`, optional, false); }; -const applyNullable = ( +const applyOptional = ( type: string, - nullable: boolean, + optional: boolean, isEnum: boolean ): string => { - if (nullable) { + if (optional) { if ( type.indexOf("Array") === 0 || type.indexOf("string") === 0 || diff --git a/packages/schema/bind/src/bindings/assemblyscript/wasm-as/templates/imported/module-type/serialization-ts.mustache b/packages/schema/bind/src/bindings/assemblyscript/wasm-as/templates/imported/module-type/serialization-ts.mustache index 842613e064..a12587be8a 100644 --- a/packages/schema/bind/src/bindings/assemblyscript/wasm-as/templates/imported/module-type/serialization-ts.mustache +++ b/packages/schema/bind/src/bindings/assemblyscript/wasm-as/templates/imported/module-type/serialization-ts.mustache @@ -50,7 +50,7 @@ export function write{{name}}Args( writer.writeInt32(input.{{#handleKeywords}}{{name}}{{/handleKeywords}}); {{/required}} {{^required}} - writer.writeNullableInt32(input.{{#handleKeywords}}{{name}}{{/handleKeywords}}); + writer.writeOptionalInt32(input.{{#handleKeywords}}{{name}}{{/handleKeywords}}); {{/required}} {{/enum}} {{#object}} diff --git a/packages/schema/bind/src/bindings/assemblyscript/wasm-as/templates/imported/object-type/serialization-ts.mustache b/packages/schema/bind/src/bindings/assemblyscript/wasm-as/templates/imported/object-type/serialization-ts.mustache index 5cba873673..1ead6c6436 100644 --- a/packages/schema/bind/src/bindings/assemblyscript/wasm-as/templates/imported/object-type/serialization-ts.mustache +++ b/packages/schema/bind/src/bindings/assemblyscript/wasm-as/templates/imported/object-type/serialization-ts.mustache @@ -52,7 +52,7 @@ export function write{{type}}(writer: Write, type: {{type}}): void { writer.writeInt32(type.{{#handleKeywords}}{{name}}{{/handleKeywords}}); {{/required}} {{^required}} - writer.writeNullableInt32(type.{{#handleKeywords}}{{name}}{{/handleKeywords}}); + writer.writeOptionalInt32(type.{{#handleKeywords}}{{name}}{{/handleKeywords}}); {{/required}} {{/enum}} writer.context().pop(); diff --git a/packages/schema/bind/src/bindings/assemblyscript/wasm-as/templates/module-type/serialization-ts.mustache b/packages/schema/bind/src/bindings/assemblyscript/wasm-as/templates/module-type/serialization-ts.mustache index f4a4b0c88e..9acc156652 100644 --- a/packages/schema/bind/src/bindings/assemblyscript/wasm-as/templates/module-type/serialization-ts.mustache +++ b/packages/schema/bind/src/bindings/assemblyscript/wasm-as/templates/module-type/serialization-ts.mustache @@ -130,7 +130,7 @@ export function write{{name}}Result(writer: Write, result: {{#return}}{{#toWasm} writer.writeInt32(result); {{/required}} {{^required}} - writer.writeNullableInt32(result); + writer.writeOptionalInt32(result); {{/required}} {{/enum}} {{#object}} diff --git a/packages/schema/bind/src/bindings/assemblyscript/wasm-as/templates/object-type/serialization-ts.mustache b/packages/schema/bind/src/bindings/assemblyscript/wasm-as/templates/object-type/serialization-ts.mustache index 1c4e29bbb1..d105327a0d 100644 --- a/packages/schema/bind/src/bindings/assemblyscript/wasm-as/templates/object-type/serialization-ts.mustache +++ b/packages/schema/bind/src/bindings/assemblyscript/wasm-as/templates/object-type/serialization-ts.mustache @@ -52,7 +52,7 @@ export function write{{type}}(writer: Write, type: {{type}}): void { writer.writeInt32(type.{{#handleKeywords}}{{name}}{{/handleKeywords}}); {{/required}} {{^required}} - writer.writeNullableInt32(type.{{#handleKeywords}}{{name}}{{/handleKeywords}}); + writer.writeOptionalInt32(type.{{#handleKeywords}}{{name}}{{/handleKeywords}}); {{/required}} {{/enum}} writer.context().pop(); diff --git a/packages/schema/bind/src/bindings/assemblyscript/wasm-as/templates/serialize_enum.mustache b/packages/schema/bind/src/bindings/assemblyscript/wasm-as/templates/serialize_enum.mustache index 36c7633254..36c482f6ce 100644 --- a/packages/schema/bind/src/bindings/assemblyscript/wasm-as/templates/serialize_enum.mustache +++ b/packages/schema/bind/src/bindings/assemblyscript/wasm-as/templates/serialize_enum.mustache @@ -2,5 +2,5 @@ writer.writeInt32(item); {{/required}} {{^required}} -writer.writeNullableInt32(item); +writer.writeOptionalInt32(item); {{/required}} diff --git a/packages/schema/bind/src/bindings/assemblyscript/wasm-as/templates/serialize_map_value.mustache b/packages/schema/bind/src/bindings/assemblyscript/wasm-as/templates/serialize_map_value.mustache index 26d9e06654..bac033f400 100644 --- a/packages/schema/bind/src/bindings/assemblyscript/wasm-as/templates/serialize_map_value.mustache +++ b/packages/schema/bind/src/bindings/assemblyscript/wasm-as/templates/serialize_map_value.mustache @@ -18,7 +18,7 @@ writer.write{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}(value, (writer: Write, writer.writeInt32(value); {{/required}} {{^required}} -writer.writeNullableInt32(value); +writer.writeOptionalInt32(value); {{/required}} {{/enum}} {{#object}} diff --git a/packages/schema/bind/src/bindings/rust/wasm-rs/functions.ts b/packages/schema/bind/src/bindings/rust/wasm-rs/functions.ts index f541719ef4..c2cedf22e0 100644 --- a/packages/schema/bind/src/bindings/rust/wasm-rs/functions.ts +++ b/packages/schema/bind/src/bindings/rust/wasm-rs/functions.ts @@ -90,7 +90,7 @@ export const toMsgPack: MustacheFunction = () => { if (type[type.length - 1] === "!") { type = type.substr(0, type.length - 1); } else { - modifier = "nullable_"; + modifier = "optional_"; } if (type[0] === "[") { @@ -141,20 +141,20 @@ export const toMsgPack: MustacheFunction = () => { export const toWasmInit: MustacheFunction = () => { return (value: string, render: (template: string) => string) => { let type = render(value); - let nullable = false; + let optional = false; - const nullableModifier = (str: string): string => { - return !nullable ? str : "None"; + const optionalModifier = (str: string): string => { + return !optional ? str : "None"; }; if (type[type.length - 1] === "!") { type = type.substr(0, type.length - 1); } else { - nullable = true; + optional = true; } if (type[0] === "[") { - return nullableModifier("vec![]"); + return optionalModifier("vec![]"); } if (type.startsWith("Map<")) { @@ -178,24 +178,24 @@ export const toWasmInit: MustacheFunction = () => { case "UInt16": case "UInt32": case "UInt64": - return nullableModifier("0"); + return optionalModifier("0"); case "String": - return nullableModifier("String::new()"); + return optionalModifier("String::new()"); case "Boolean": - return nullableModifier("false"); + return optionalModifier("false"); case "Bytes": - return nullableModifier("vec![]"); + return optionalModifier("vec![]"); case "BigInt": - return nullableModifier("BigInt::default()"); + return optionalModifier("BigInt::default()"); case "BigNumber": - return nullableModifier("BigNumber::default()"); + return optionalModifier("BigNumber::default()"); case "JSON": - return nullableModifier("JSON::Value::Null"); + return optionalModifier("JSON::Value::Null"); default: if (type.includes("Enum_")) { - return nullableModifier(`${toWasm()(value, render)}::_MAX_`); + return optionalModifier(`${toWasm()(value, render)}::_MAX_`); } else { - return nullableModifier(`${toWasm()(value, render)}::new()`); + return optionalModifier(`${toWasm()(value, render)}::new()`); } } }; @@ -206,19 +206,19 @@ export const toWasm: MustacheFunction = () => { let type = render(value); let objectType = false; - let nullable = false; + let optional = false; if (type[type.length - 1] === "!") { type = type.substr(0, type.length - 1); } else { - nullable = true; + optional = true; } if (type[0] === "[") { - return toWasmArray(type, nullable); + return toWasmArray(type, optional); } if (type.startsWith("Map<")) { - return toWasmMap(type, nullable); + return toWasmMap(type, optional); } switch (type) { @@ -278,8 +278,8 @@ export const toWasm: MustacheFunction = () => { } return objectType - ? applyNullable(type, nullable) - : applyNullable(type, nullable); + ? applyOptional(type, optional) + : applyOptional(type, optional); }; }; @@ -295,7 +295,7 @@ export const detectKeyword: MustacheFunction = () => { }; }; -const toWasmArray = (type: string, nullable: boolean): string => { +const toWasmArray = (type: string, optional: boolean): string => { const result = type.match(/(\[)([[\]A-Za-z1-9_.!]+)(\])/); if (!result || result.length !== 4) { @@ -303,10 +303,10 @@ const toWasmArray = (type: string, nullable: boolean): string => { } const wasmType = toWasm()(result[2], (str) => str); - return applyNullable("Vec<" + wasmType + ">", nullable); + return applyOptional("Vec<" + wasmType + ">", optional); }; -const toWasmMap = (type: string, nullable: boolean): string => { +const toWasmMap = (type: string, optional: boolean): string => { const firstOpenBracketIdx = type.indexOf("<"); const lastCloseBracketIdx = type.lastIndexOf(">"); @@ -326,11 +326,11 @@ const toWasmMap = (type: string, nullable: boolean): string => { const keyType = toWasm()(keyValTypes[0], (str) => str); const valType = toWasm()(keyValTypes[1], (str) => str); - return applyNullable(`Map<${keyType}, ${valType}>`, nullable); + return applyOptional(`Map<${keyType}, ${valType}>`, optional); }; -const applyNullable = (type: string, nullable: boolean): string => { - if (nullable) { +const applyOptional = (type: string, optional: boolean): string => { + if (optional) { return `Option<${type}>`; } else { return type; diff --git a/packages/schema/bind/src/bindings/rust/wasm-rs/templates/imported/module-type/serialization-rs.mustache b/packages/schema/bind/src/bindings/rust/wasm-rs/templates/imported/module-type/serialization-rs.mustache index 36712389f3..2cda71ad48 100644 --- a/packages/schema/bind/src/bindings/rust/wasm-rs/templates/imported/module-type/serialization-rs.mustache +++ b/packages/schema/bind/src/bindings/rust/wasm-rs/templates/imported/module-type/serialization-rs.mustache @@ -72,7 +72,7 @@ pub fn write_{{#toLower}}{{name}}{{/toLower}}_args(input: &Input{{#toU writer.write_i32(&(input.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}} as i32))?; {{/required}} {{^required}} - writer.write_nullable_i32(&input.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}.map(|f| f as i32))?; + writer.write_optional_i32(&input.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}.map(|f| f as i32))?; {{/required}} {{/enum}} {{#object}} diff --git a/packages/schema/bind/src/bindings/rust/wasm-rs/templates/imported/object-type/serialization-rs.mustache b/packages/schema/bind/src/bindings/rust/wasm-rs/templates/imported/object-type/serialization-rs.mustache index ac73008645..1979361229 100644 --- a/packages/schema/bind/src/bindings/rust/wasm-rs/templates/imported/object-type/serialization-rs.mustache +++ b/packages/schema/bind/src/bindings/rust/wasm-rs/templates/imported/object-type/serialization-rs.mustache @@ -75,7 +75,7 @@ pub fn write_{{#toLower}}{{type}}{{/toLower}}(input: &{{#toUpper}}{{ty writer.write_i32(&(input.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}} as i32))?; {{/required}} {{^required}} - writer.write_nullable_i32(&input.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}.map(|f| f as i32))?; + writer.write_optional_i32(&input.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}.map(|f| f as i32))?; {{/required}} {{/enum}} writer.context().pop(); diff --git a/packages/schema/bind/src/bindings/rust/wasm-rs/templates/module-type/serialization-rs.mustache b/packages/schema/bind/src/bindings/rust/wasm-rs/templates/module-type/serialization-rs.mustache index 0c0105b777..52c1264a0a 100644 --- a/packages/schema/bind/src/bindings/rust/wasm-rs/templates/module-type/serialization-rs.mustache +++ b/packages/schema/bind/src/bindings/rust/wasm-rs/templates/module-type/serialization-rs.mustache @@ -153,7 +153,7 @@ pub fn write_{{#toLower}}{{name}}{{/toLower}}_result(result: {{#return writer.write_i32(&(*result as i32))?; {{/required}} {{^required}} - writer.write_nullable_i32(&result.map(|f| f as i32))?; + writer.write_optional_i32(&result.map(|f| f as i32))?; {{/required}} {{/enum}} {{#object}} diff --git a/packages/schema/bind/src/bindings/rust/wasm-rs/templates/object-type/serialization-rs.mustache b/packages/schema/bind/src/bindings/rust/wasm-rs/templates/object-type/serialization-rs.mustache index 106e788b9e..aca295c9f2 100644 --- a/packages/schema/bind/src/bindings/rust/wasm-rs/templates/object-type/serialization-rs.mustache +++ b/packages/schema/bind/src/bindings/rust/wasm-rs/templates/object-type/serialization-rs.mustache @@ -75,7 +75,7 @@ pub fn write_{{#toLower}}{{type}}{{/toLower}}(input: &{{#toUpper}}{{ty writer.write_i32(&(input.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}} as i32))?; {{/required}} {{^required}} - writer.write_nullable_i32(&input.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}.map(|f| f as i32))?; + writer.write_optional_i32(&input.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}.map(|f| f as i32))?; {{/required}} {{/enum}} writer.context().pop(); diff --git a/packages/schema/bind/src/bindings/rust/wasm-rs/templates/serialize_enum.mustache b/packages/schema/bind/src/bindings/rust/wasm-rs/templates/serialize_enum.mustache index e5e3acf95a..5ada8b40f4 100644 --- a/packages/schema/bind/src/bindings/rust/wasm-rs/templates/serialize_enum.mustache +++ b/packages/schema/bind/src/bindings/rust/wasm-rs/templates/serialize_enum.mustache @@ -2,5 +2,5 @@ writer.write_i32(&(*item as i32)) {{/required}} {{^required}} -writer.write_nullable_i32(&item.map(|f| f as i32)) +writer.write_optional_i32(&item.map(|f| f as i32)) {{/required}} \ No newline at end of file diff --git a/packages/schema/bind/src/bindings/rust/wasm-rs/templates/serialize_map_value.mustache b/packages/schema/bind/src/bindings/rust/wasm-rs/templates/serialize_map_value.mustache index 985444e971..00959f1344 100644 --- a/packages/schema/bind/src/bindings/rust/wasm-rs/templates/serialize_map_value.mustache +++ b/packages/schema/bind/src/bindings/rust/wasm-rs/templates/serialize_map_value.mustache @@ -20,7 +20,7 @@ writer.write_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower writer.write_i32(&(*value as i32)) {{/required}} {{^required}} -writer.write_nullable_i32(&value.map(|f| f as i32)) +writer.write_optional_i32(&value.map(|f| f as i32)) {{/required}} {{/enum}} {{#object}} diff --git a/packages/schema/bind/src/bindings/typescript/functions.ts b/packages/schema/bind/src/bindings/typescript/functions.ts index bc80d02255..cf7dc16435 100644 --- a/packages/schema/bind/src/bindings/typescript/functions.ts +++ b/packages/schema/bind/src/bindings/typescript/functions.ts @@ -49,19 +49,19 @@ const _toTypescript = ( ) => { let type = render(value); - let nullable = false; + let optional = false; if (type[type.length - 1] === "!") { type = type.substring(0, type.length - 1); } else { - nullable = true; + optional = true; } if (type[0] === "[") { - return toTypescriptArray(type, nullable); + return toTypescriptArray(type, optional); } if (type.startsWith("Map<")) { - return toTypescriptMap(type, nullable); + return toTypescriptMap(type, optional); } switch (type) { @@ -77,11 +77,11 @@ const _toTypescript = ( } return undefinable - ? applyUndefinable(type, nullable) - : applyNullable(type, nullable); + ? applyUndefinable(type, optional) + : applyOptional(type, optional); }; -const toTypescriptArray = (type: string, nullable: boolean): string => { +const toTypescriptArray = (type: string, optional: boolean): string => { const result = type.match(/(\[)([[\]A-Za-z0-9_.!]+)(\])/); if (!result || result.length !== 4) { @@ -89,10 +89,10 @@ const toTypescriptArray = (type: string, nullable: boolean): string => { } const tsType = _toTypescript(result[2], (str) => str); - return applyNullable("Array<" + tsType + ">", nullable); + return applyOptional("Array<" + tsType + ">", optional); }; -const toTypescriptMap = (type: string, nullable: boolean): string => { +const toTypescriptMap = (type: string, optional: boolean): string => { const openAngleBracketIdx = type.indexOf("<"); const closeAngleBracketIdx = type.lastIndexOf(">"); @@ -104,11 +104,11 @@ const toTypescriptMap = (type: string, nullable: boolean): string => { const tsKeyType = _toTypescript(keyType, (str) => str); const tsValType = _toTypescript(valtype, (str) => str, true); - return applyNullable(`Map<${tsKeyType}, ${tsValType}>`, nullable); + return applyOptional(`Map<${tsKeyType}, ${tsValType}>`, optional); }; -const applyNullable = (type: string, nullable: boolean): string => { - if (nullable) { +const applyOptional = (type: string, optional: boolean): string => { + if (optional) { return `${type} | null`; } else { return type; diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-as/AnotherType/serialization.ts b/packages/test-cases/cases/bind/sanity/output/wasm-as/AnotherType/serialization.ts index ed4fbeff94..5d1dfc6a1b 100644 --- a/packages/test-cases/cases/bind/sanity/output/wasm-as/AnotherType/serialization.ts +++ b/packages/test-cases/cases/bind/sanity/output/wasm-as/AnotherType/serialization.ts @@ -28,7 +28,7 @@ export function writeAnotherType(writer: Write, type: AnotherType): void { writer.writeMapLength(3); writer.context().push("prop", "string | null", "writing property"); writer.writeString("prop"); - writer.writeNullableString(type.prop); + writer.writeOptionalString(type.prop); writer.context().pop(); writer.context().push("circular", "Types.CustomType | null", "writing property"); writer.writeString("circular"); @@ -40,7 +40,7 @@ export function writeAnotherType(writer: Write, type: AnotherType): void { writer.context().pop(); writer.context().push("const", "string | null", "writing property"); writer.writeString("const"); - writer.writeNullableString(type.m_const); + writer.writeOptionalString(type.m_const); writer.context().pop(); } @@ -64,7 +64,7 @@ export function readAnotherType(reader: Read): AnotherType { reader.context().push(field, "unknown", "searching for property type"); if (field == "prop") { reader.context().push(field, "string | null", "type found, reading property"); - _prop = reader.readNullableString(); + _prop = reader.readOptionalString(); reader.context().pop(); } else if (field == "circular") { @@ -78,7 +78,7 @@ export function readAnotherType(reader: Read): AnotherType { } else if (field == "const") { reader.context().push(field, "string | null", "type found, reading property"); - _const = reader.readNullableString(); + _const = reader.readOptionalString(); reader.context().pop(); } reader.context().pop(); diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-as/CustomType/serialization.ts b/packages/test-cases/cases/bind/sanity/output/wasm-as/CustomType/serialization.ts index 5b8a71d97a..250baed30b 100644 --- a/packages/test-cases/cases/bind/sanity/output/wasm-as/CustomType/serialization.ts +++ b/packages/test-cases/cases/bind/sanity/output/wasm-as/CustomType/serialization.ts @@ -32,7 +32,7 @@ export function writeCustomType(writer: Write, type: CustomType): void { writer.context().pop(); writer.context().push("optStr", "string | null", "writing property"); writer.writeString("optStr"); - writer.writeNullableString(type.optStr); + writer.writeOptionalString(type.optStr); writer.context().pop(); writer.context().push("u", "u32", "writing property"); writer.writeString("u"); @@ -40,7 +40,7 @@ export function writeCustomType(writer: Write, type: CustomType): void { writer.context().pop(); writer.context().push("optU", "Option", "writing property"); writer.writeString("optU"); - writer.writeNullableUInt32(type.optU); + writer.writeOptionalUInt32(type.optU); writer.context().pop(); writer.context().push("u8", "u8", "writing property"); writer.writeString("u8"); @@ -76,7 +76,7 @@ export function writeCustomType(writer: Write, type: CustomType): void { writer.context().pop(); writer.context().push("optBigint", "BigInt | null", "writing property"); writer.writeString("optBigint"); - writer.writeNullableBigInt(type.optBigint); + writer.writeOptionalBigInt(type.optBigint); writer.context().pop(); writer.context().push("bignumber", "BigNumber", "writing property"); writer.writeString("bignumber"); @@ -84,7 +84,7 @@ export function writeCustomType(writer: Write, type: CustomType): void { writer.context().pop(); writer.context().push("optBignumber", "BigNumber | null", "writing property"); writer.writeString("optBignumber"); - writer.writeNullableBigNumber(type.optBignumber); + writer.writeOptionalBigNumber(type.optBignumber); writer.context().pop(); writer.context().push("json", "JSON.Value", "writing property"); writer.writeString("json"); @@ -92,7 +92,7 @@ export function writeCustomType(writer: Write, type: CustomType): void { writer.context().pop(); writer.context().push("optJson", "JSON.Value | null", "writing property"); writer.writeString("optJson"); - writer.writeNullableJSON(type.optJson); + writer.writeOptionalJSON(type.optJson); writer.context().pop(); writer.context().push("bytes", "ArrayBuffer", "writing property"); writer.writeString("bytes"); @@ -100,7 +100,7 @@ export function writeCustomType(writer: Write, type: CustomType): void { writer.context().pop(); writer.context().push("optBytes", "ArrayBuffer | null", "writing property"); writer.writeString("optBytes"); - writer.writeNullableBytes(type.optBytes); + writer.writeOptionalBytes(type.optBytes); writer.context().pop(); writer.context().push("boolean", "bool", "writing property"); writer.writeString("boolean"); @@ -108,7 +108,7 @@ export function writeCustomType(writer: Write, type: CustomType): void { writer.context().pop(); writer.context().push("optBoolean", "Option", "writing property"); writer.writeString("optBoolean"); - writer.writeNullableBool(type.optBoolean); + writer.writeOptionalBool(type.optBoolean); writer.context().pop(); writer.context().push("uArray", "Array", "writing property"); writer.writeString("uArray"); @@ -118,20 +118,20 @@ export function writeCustomType(writer: Write, type: CustomType): void { writer.context().pop(); writer.context().push("uOptArray", "Array | null", "writing property"); writer.writeString("uOptArray"); - writer.writeNullableArray(type.uOptArray, (writer: Write, item: u32): void => { + writer.writeOptionalArray(type.uOptArray, (writer: Write, item: u32): void => { writer.writeUInt32(item); }); writer.context().pop(); writer.context().push("optUOptArray", "Array> | null", "writing property"); writer.writeString("optUOptArray"); - writer.writeNullableArray(type.optUOptArray, (writer: Write, item: Option): void => { - writer.writeNullableUInt32(item); + writer.writeOptionalArray(type.optUOptArray, (writer: Write, item: Option): void => { + writer.writeOptionalUInt32(item); }); writer.context().pop(); writer.context().push("optStrOptArray", "Array | null", "writing property"); writer.writeString("optStrOptArray"); - writer.writeNullableArray(type.optStrOptArray, (writer: Write, item: string | null): void => { - writer.writeNullableString(item); + writer.writeOptionalArray(type.optStrOptArray, (writer: Write, item: string | null): void => { + writer.writeOptionalString(item); }); writer.context().pop(); writer.context().push("uArrayArray", "Array>", "writing property"); @@ -145,15 +145,15 @@ export function writeCustomType(writer: Write, type: CustomType): void { writer.context().push("uOptArrayOptArray", "Array> | null>", "writing property"); writer.writeString("uOptArrayOptArray"); writer.writeArray(type.uOptArrayOptArray, (writer: Write, item: Array> | null): void => { - writer.writeNullableArray(item, (writer: Write, item: Option): void => { - writer.writeNullableUInt32(item); + writer.writeOptionalArray(item, (writer: Write, item: Option): void => { + writer.writeOptionalUInt32(item); }); }); writer.context().pop(); writer.context().push("uArrayOptArrayArray", "Array> | null>", "writing property"); writer.writeString("uArrayOptArrayArray"); writer.writeArray(type.uArrayOptArrayArray, (writer: Write, item: Array> | null): void => { - writer.writeNullableArray(item, (writer: Write, item: Array): void => { + writer.writeOptionalArray(item, (writer: Write, item: Array): void => { writer.writeArray(item, (writer: Write, item: u32): void => { writer.writeUInt32(item); }); @@ -162,10 +162,10 @@ export function writeCustomType(writer: Write, type: CustomType): void { writer.context().pop(); writer.context().push("crazyArray", "Array | null>> | null> | null", "writing property"); writer.writeString("crazyArray"); - writer.writeNullableArray(type.crazyArray, (writer: Write, item: Array | null>> | null): void => { - writer.writeNullableArray(item, (writer: Write, item: Array | null>): void => { + writer.writeOptionalArray(type.crazyArray, (writer: Write, item: Array | null>> | null): void => { + writer.writeOptionalArray(item, (writer: Write, item: Array | null>): void => { writer.writeArray(item, (writer: Write, item: Array | null): void => { - writer.writeNullableArray(item, (writer: Write, item: u32): void => { + writer.writeOptionalArray(item, (writer: Write, item: u32): void => { writer.writeUInt32(item); }); }); @@ -192,7 +192,7 @@ export function writeCustomType(writer: Write, type: CustomType): void { writer.context().pop(); writer.context().push("optObjectArray", "Array | null", "writing property"); writer.writeString("optObjectArray"); - writer.writeNullableArray(type.optObjectArray, (writer: Write, item: Types.AnotherType | null): void => { + writer.writeOptionalArray(type.optObjectArray, (writer: Write, item: Types.AnotherType | null): void => { if (item) { Types.AnotherType.write(writer, item as Types.AnotherType); } else { @@ -206,7 +206,7 @@ export function writeCustomType(writer: Write, type: CustomType): void { writer.context().pop(); writer.context().push("optEnum", "Option", "writing property"); writer.writeString("optEnum"); - writer.writeNullableInt32(type.optEnum); + writer.writeOptionalInt32(type.optEnum); writer.context().pop(); writer.context().push("enumArray", "Array", "writing property"); writer.writeString("enumArray"); @@ -216,8 +216,8 @@ export function writeCustomType(writer: Write, type: CustomType): void { writer.context().pop(); writer.context().push("optEnumArray", "Array> | null", "writing property"); writer.writeString("optEnumArray"); - writer.writeNullableArray(type.optEnumArray, (writer: Write, item: Option): void => { - writer.writeNullableInt32(item); + writer.writeOptionalArray(type.optEnumArray, (writer: Write, item: Option): void => { + writer.writeOptionalInt32(item); }); writer.context().pop(); } @@ -304,7 +304,7 @@ export function readCustomType(reader: Read): CustomType { } else if (field == "optStr") { reader.context().push(field, "string | null", "type found, reading property"); - _optStr = reader.readNullableString(); + _optStr = reader.readOptionalString(); reader.context().pop(); } else if (field == "u") { @@ -315,7 +315,7 @@ export function readCustomType(reader: Read): CustomType { } else if (field == "optU") { reader.context().push(field, "Option", "type found, reading property"); - _optU = reader.readNullableUInt32(); + _optU = reader.readOptionalUInt32(); reader.context().pop(); } else if (field == "u8") { @@ -368,7 +368,7 @@ export function readCustomType(reader: Read): CustomType { } else if (field == "optBigint") { reader.context().push(field, "BigInt | null", "type found, reading property"); - _optBigint = reader.readNullableBigInt(); + _optBigint = reader.readOptionalBigInt(); reader.context().pop(); } else if (field == "bignumber") { @@ -379,7 +379,7 @@ export function readCustomType(reader: Read): CustomType { } else if (field == "optBignumber") { reader.context().push(field, "BigNumber | null", "type found, reading property"); - _optBignumber = reader.readNullableBigNumber(); + _optBignumber = reader.readOptionalBigNumber(); reader.context().pop(); } else if (field == "json") { @@ -390,7 +390,7 @@ export function readCustomType(reader: Read): CustomType { } else if (field == "optJson") { reader.context().push(field, "JSON.Value | null", "type found, reading property"); - _optJson = reader.readNullableJSON(); + _optJson = reader.readOptionalJSON(); reader.context().pop(); } else if (field == "bytes") { @@ -401,7 +401,7 @@ export function readCustomType(reader: Read): CustomType { } else if (field == "optBytes") { reader.context().push(field, "ArrayBuffer | null", "type found, reading property"); - _optBytes = reader.readNullableBytes(); + _optBytes = reader.readOptionalBytes(); reader.context().pop(); } else if (field == "boolean") { @@ -412,7 +412,7 @@ export function readCustomType(reader: Read): CustomType { } else if (field == "optBoolean") { reader.context().push(field, "Option", "type found, reading property"); - _optBoolean = reader.readNullableBool(); + _optBoolean = reader.readOptionalBool(); reader.context().pop(); } else if (field == "uArray") { @@ -425,22 +425,22 @@ export function readCustomType(reader: Read): CustomType { } else if (field == "uOptArray") { reader.context().push(field, "Array | null", "type found, reading property"); - _uOptArray = reader.readNullableArray((reader: Read): u32 => { + _uOptArray = reader.readOptionalArray((reader: Read): u32 => { return reader.readUInt32(); }); reader.context().pop(); } else if (field == "optUOptArray") { reader.context().push(field, "Array> | null", "type found, reading property"); - _optUOptArray = reader.readNullableArray((reader: Read): Option => { - return reader.readNullableUInt32(); + _optUOptArray = reader.readOptionalArray((reader: Read): Option => { + return reader.readOptionalUInt32(); }); reader.context().pop(); } else if (field == "optStrOptArray") { reader.context().push(field, "Array | null", "type found, reading property"); - _optStrOptArray = reader.readNullableArray((reader: Read): string | null => { - return reader.readNullableString(); + _optStrOptArray = reader.readOptionalArray((reader: Read): string | null => { + return reader.readOptionalString(); }); reader.context().pop(); } @@ -457,8 +457,8 @@ export function readCustomType(reader: Read): CustomType { else if (field == "uOptArrayOptArray") { reader.context().push(field, "Array> | null>", "type found, reading property"); _uOptArrayOptArray = reader.readArray((reader: Read): Array> | null => { - return reader.readNullableArray((reader: Read): Option => { - return reader.readNullableUInt32(); + return reader.readOptionalArray((reader: Read): Option => { + return reader.readOptionalUInt32(); }); }); _uOptArrayOptArraySet = true; @@ -467,7 +467,7 @@ export function readCustomType(reader: Read): CustomType { else if (field == "uArrayOptArrayArray") { reader.context().push(field, "Array> | null>", "type found, reading property"); _uArrayOptArrayArray = reader.readArray((reader: Read): Array> | null => { - return reader.readNullableArray((reader: Read): Array => { + return reader.readOptionalArray((reader: Read): Array => { return reader.readArray((reader: Read): u32 => { return reader.readUInt32(); }); @@ -478,10 +478,10 @@ export function readCustomType(reader: Read): CustomType { } else if (field == "crazyArray") { reader.context().push(field, "Array | null>> | null> | null", "type found, reading property"); - _crazyArray = reader.readNullableArray((reader: Read): Array | null>> | null => { - return reader.readNullableArray((reader: Read): Array | null> => { + _crazyArray = reader.readOptionalArray((reader: Read): Array | null>> | null => { + return reader.readOptionalArray((reader: Read): Array | null> => { return reader.readArray((reader: Read): Array | null => { - return reader.readNullableArray((reader: Read): u32 => { + return reader.readOptionalArray((reader: Read): u32 => { return reader.readUInt32(); }); }); @@ -516,7 +516,7 @@ export function readCustomType(reader: Read): CustomType { } else if (field == "optObjectArray") { reader.context().push(field, "Array | null", "type found, reading property"); - _optObjectArray = reader.readNullableArray((reader: Read): Types.AnotherType | null => { + _optObjectArray = reader.readOptionalArray((reader: Read): Types.AnotherType | null => { let object: Types.AnotherType | null = null; if (!reader.isNextNil()) { object = Types.AnotherType.read(reader); @@ -575,7 +575,7 @@ export function readCustomType(reader: Read): CustomType { } else if (field == "optEnumArray") { reader.context().push(field, "Array> | null", "type found, reading property"); - _optEnumArray = reader.readNullableArray((reader: Read): Option => { + _optEnumArray = reader.readOptionalArray((reader: Read): Option => { let value: Option; if (!reader.isNextNil()) { if (reader.isNextString()) { diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-as/Env/serialization.ts b/packages/test-cases/cases/bind/sanity/output/wasm-as/Env/serialization.ts index e83f1c9ca1..21dcd77dec 100644 --- a/packages/test-cases/cases/bind/sanity/output/wasm-as/Env/serialization.ts +++ b/packages/test-cases/cases/bind/sanity/output/wasm-as/Env/serialization.ts @@ -32,14 +32,14 @@ export function writeEnv(writer: Write, type: Env): void { writer.context().pop(); writer.context().push("optProp", "string | null", "writing property"); writer.writeString("optProp"); - writer.writeNullableString(type.optProp); + writer.writeOptionalString(type.optProp); writer.context().pop(); writer.context().push("optMap", "Map> | null", "writing property"); writer.writeString("optMap"); - writer.writeNullableExtGenericMap(type.optMap, (writer: Write, key: string) => { + writer.writeOptionalExtGenericMap(type.optMap, (writer: Write, key: string) => { writer.writeString(key); }, (writer: Write, value: Option): void => { - writer.writeNullableInt32(value); + writer.writeOptionalInt32(value); }); writer.context().pop(); } @@ -71,15 +71,15 @@ export function readEnv(reader: Read): Env { } else if (field == "optProp") { reader.context().push(field, "string | null", "type found, reading property"); - _optProp = reader.readNullableString(); + _optProp = reader.readOptionalString(); reader.context().pop(); } else if (field == "optMap") { reader.context().push(field, "Map> | null", "type found, reading property"); - _optMap = reader.readNullableExtGenericMap((reader: Read): string => { + _optMap = reader.readOptionalExtGenericMap((reader: Read): string => { return reader.readString(); }, (reader: Read): Option => { - return reader.readNullableInt32(); + return reader.readOptionalInt32(); }); reader.context().pop(); } diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-as/Module/serialization.ts b/packages/test-cases/cases/bind/sanity/output/wasm-as/Module/serialization.ts index f214d2abae..013e3fe4d7 100644 --- a/packages/test-cases/cases/bind/sanity/output/wasm-as/Module/serialization.ts +++ b/packages/test-cases/cases/bind/sanity/output/wasm-as/Module/serialization.ts @@ -52,7 +52,7 @@ export function deserializemoduleMethodArgs(argsBuf: ArrayBuffer): Input_moduleM } else if (field == "optStr") { reader.context().push(field, "string | null", "type found, reading property"); - _optStr = reader.readNullableString(); + _optStr = reader.readOptionalString(); reader.context().pop(); } else if (field == "en") { @@ -105,7 +105,7 @@ export function deserializemoduleMethodArgs(argsBuf: ArrayBuffer): Input_moduleM } else if (field == "optEnumArray") { reader.context().push(field, "Array> | null", "type found, reading property"); - _optEnumArray = reader.readNullableArray((reader: Read): Option => { + _optEnumArray = reader.readOptionalArray((reader: Read): Option => { let value: Option; if (!reader.isNextNil()) { if (reader.isNextString()) { @@ -230,7 +230,7 @@ export function deserializeobjectMethodArgs(argsBuf: ArrayBuffer): Input_objectM } else if (field == "optObjectArray") { reader.context().push(field, "Array | null", "type found, reading property"); - _optObjectArray = reader.readNullableArray((reader: Read): Types.AnotherType | null => { + _optObjectArray = reader.readOptionalArray((reader: Read): Types.AnotherType | null => { let object: Types.AnotherType | null = null; if (!reader.isNextNil()) { object = Types.AnotherType.read(reader); diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_Module/serialization.ts b/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_Module/serialization.ts index d1bb72d7e5..8aa35bdce8 100644 --- a/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_Module/serialization.ts +++ b/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_Module/serialization.ts @@ -50,7 +50,7 @@ export function writeimportedMethodArgs( writer.context().pop(); writer.context().push("optStr", "string | null", "writing property"); writer.writeString("optStr"); - writer.writeNullableString(input.optStr); + writer.writeOptionalString(input.optStr); writer.context().pop(); writer.context().push("u", "u32", "writing property"); writer.writeString("u"); @@ -58,13 +58,13 @@ export function writeimportedMethodArgs( writer.context().pop(); writer.context().push("optU", "Option", "writing property"); writer.writeString("optU"); - writer.writeNullableUInt32(input.optU); + writer.writeOptionalUInt32(input.optU); writer.context().pop(); writer.context().push("uArrayArray", "Array> | null>", "writing property"); writer.writeString("uArrayArray"); writer.writeArray(input.uArrayArray, (writer: Write, item: Array> | null): void => { - writer.writeNullableArray(item, (writer: Write, item: Option): void => { - writer.writeNullableUInt32(item); + writer.writeOptionalArray(item, (writer: Write, item: Option): void => { + writer.writeOptionalUInt32(item); }); }); writer.context().pop(); @@ -88,7 +88,7 @@ export function writeimportedMethodArgs( writer.context().pop(); writer.context().push("optObjectArray", "Array | null", "writing property"); writer.writeString("optObjectArray"); - writer.writeNullableArray(input.optObjectArray, (writer: Write, item: Types.TestImport_Object | null): void => { + writer.writeOptionalArray(input.optObjectArray, (writer: Write, item: Types.TestImport_Object | null): void => { if (item) { Types.TestImport_Object.write(writer, item as Types.TestImport_Object); } else { @@ -102,7 +102,7 @@ export function writeimportedMethodArgs( writer.context().pop(); writer.context().push("optEnum", "Option", "writing property"); writer.writeString("optEnum"); - writer.writeNullableInt32(input.optEnum); + writer.writeOptionalInt32(input.optEnum); writer.context().pop(); writer.context().push("enumArray", "Array", "writing property"); writer.writeString("enumArray"); @@ -112,8 +112,8 @@ export function writeimportedMethodArgs( writer.context().pop(); writer.context().push("optEnumArray", "Array> | null", "writing property"); writer.writeString("optEnumArray"); - writer.writeNullableArray(input.optEnumArray, (writer: Write, item: Option): void => { - writer.writeNullableInt32(item); + writer.writeOptionalArray(input.optEnumArray, (writer: Write, item: Option): void => { + writer.writeOptionalInt32(item); }); writer.context().pop(); } diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_Object/serialization.ts b/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_Object/serialization.ts index 9b588e9ca7..423b9b892b 100644 --- a/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_Object/serialization.ts +++ b/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_Object/serialization.ts @@ -46,7 +46,7 @@ export function writeTestImport_Object(writer: Write, type: TestImport_Object): writer.context().pop(); writer.context().push("optObjectArray", "Array | null", "writing property"); writer.writeString("optObjectArray"); - writer.writeNullableArray(type.optObjectArray, (writer: Write, item: Types.TestImport_AnotherObject | null): void => { + writer.writeOptionalArray(type.optObjectArray, (writer: Write, item: Types.TestImport_AnotherObject | null): void => { if (item) { Types.TestImport_AnotherObject.write(writer, item as Types.TestImport_AnotherObject); } else { @@ -60,7 +60,7 @@ export function writeTestImport_Object(writer: Write, type: TestImport_Object): writer.context().pop(); writer.context().push("optEnum", "Option", "writing property"); writer.writeString("optEnum"); - writer.writeNullableInt32(type.optEnum); + writer.writeOptionalInt32(type.optEnum); writer.context().pop(); writer.context().push("enumArray", "Array", "writing property"); writer.writeString("enumArray"); @@ -70,8 +70,8 @@ export function writeTestImport_Object(writer: Write, type: TestImport_Object): writer.context().pop(); writer.context().push("optEnumArray", "Array> | null", "writing property"); writer.writeString("optEnumArray"); - writer.writeNullableArray(type.optEnumArray, (writer: Write, item: Option): void => { - writer.writeNullableInt32(item); + writer.writeOptionalArray(type.optEnumArray, (writer: Write, item: Option): void => { + writer.writeOptionalInt32(item); }); writer.context().pop(); } @@ -130,7 +130,7 @@ export function readTestImport_Object(reader: Read): TestImport_Object { } else if (field == "optObjectArray") { reader.context().push(field, "Array | null", "type found, reading property"); - _optObjectArray = reader.readNullableArray((reader: Read): Types.TestImport_AnotherObject | null => { + _optObjectArray = reader.readOptionalArray((reader: Read): Types.TestImport_AnotherObject | null => { let object: Types.TestImport_AnotherObject | null = null; if (!reader.isNextNil()) { object = Types.TestImport_AnotherObject.read(reader); @@ -189,7 +189,7 @@ export function readTestImport_Object(reader: Read): TestImport_Object { } else if (field == "optEnumArray") { reader.context().push(field, "Array> | null", "type found, reading property"); - _optEnumArray = reader.readNullableArray((reader: Read): Option => { + _optEnumArray = reader.readOptionalArray((reader: Read): Option => { let value: Option; if (!reader.isNextNil()) { if (reader.isNextString()) { diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-rs/another_type/serialization.rs b/packages/test-cases/cases/bind/sanity/output/wasm-rs/another_type/serialization.rs index 9f93c92f32..955298c224 100644 --- a/packages/test-cases/cases/bind/sanity/output/wasm-rs/another_type/serialization.rs +++ b/packages/test-cases/cases/bind/sanity/output/wasm-rs/another_type/serialization.rs @@ -28,7 +28,7 @@ pub fn write_another_type(input: &AnotherType, writer: &mut W) -> Resu writer.write_map_length(&3)?; writer.context().push("prop", "Option", "writing property"); writer.write_string("prop")?; - writer.write_nullable_string(&input.prop)?; + writer.write_optional_string(&input.prop)?; writer.context().pop(); writer.context().push("circular", "Option", "writing property"); writer.write_string("circular")?; @@ -40,7 +40,7 @@ pub fn write_another_type(input: &AnotherType, writer: &mut W) -> Resu writer.context().pop(); writer.context().push("const", "Option", "writing property"); writer.write_string("const")?; - writer.write_nullable_string(&input.m_const)?; + writer.write_optional_string(&input.m_const)?; writer.context().pop(); Ok(()) } @@ -66,7 +66,7 @@ pub fn read_another_type(reader: &mut R) -> Result { reader.context().push(&field, "Option", "type found, reading property"); - _prop = reader.read_nullable_string()?; + _prop = reader.read_optional_string()?; reader.context().pop(); } "circular" => { @@ -82,7 +82,7 @@ pub fn read_another_type(reader: &mut R) -> Result { reader.context().push(&field, "Option", "type found, reading property"); - _const = reader.read_nullable_string()?; + _const = reader.read_optional_string()?; reader.context().pop(); } err => return Err(DecodeError::UnknownFieldName(err.to_string())), diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-rs/custom_type/serialization.rs b/packages/test-cases/cases/bind/sanity/output/wasm-rs/custom_type/serialization.rs index fd55943a66..67c9831780 100644 --- a/packages/test-cases/cases/bind/sanity/output/wasm-rs/custom_type/serialization.rs +++ b/packages/test-cases/cases/bind/sanity/output/wasm-rs/custom_type/serialization.rs @@ -37,7 +37,7 @@ pub fn write_custom_type(input: &CustomType, writer: &mut W) -> Result writer.context().pop(); writer.context().push("optStr", "Option", "writing property"); writer.write_string("optStr")?; - writer.write_nullable_string(&input.opt_str)?; + writer.write_optional_string(&input.opt_str)?; writer.context().pop(); writer.context().push("u", "u32", "writing property"); writer.write_string("u")?; @@ -45,7 +45,7 @@ pub fn write_custom_type(input: &CustomType, writer: &mut W) -> Result writer.context().pop(); writer.context().push("optU", "Option", "writing property"); writer.write_string("optU")?; - writer.write_nullable_u32(&input.opt_u)?; + writer.write_optional_u32(&input.opt_u)?; writer.context().pop(); writer.context().push("u8", "u8", "writing property"); writer.write_string("u8")?; @@ -81,7 +81,7 @@ pub fn write_custom_type(input: &CustomType, writer: &mut W) -> Result writer.context().pop(); writer.context().push("optBigint", "Option", "writing property"); writer.write_string("optBigint")?; - writer.write_nullable_bigint(&input.opt_bigint)?; + writer.write_optional_bigint(&input.opt_bigint)?; writer.context().pop(); writer.context().push("bignumber", "BigNumber", "writing property"); writer.write_string("bignumber")?; @@ -89,7 +89,7 @@ pub fn write_custom_type(input: &CustomType, writer: &mut W) -> Result writer.context().pop(); writer.context().push("optBignumber", "Option", "writing property"); writer.write_string("optBignumber")?; - writer.write_nullable_bignumber(&input.opt_bignumber)?; + writer.write_optional_bignumber(&input.opt_bignumber)?; writer.context().pop(); writer.context().push("json", "JSON::Value", "writing property"); writer.write_string("json")?; @@ -97,7 +97,7 @@ pub fn write_custom_type(input: &CustomType, writer: &mut W) -> Result writer.context().pop(); writer.context().push("optJson", "Option", "writing property"); writer.write_string("optJson")?; - writer.write_nullable_json(&input.opt_json)?; + writer.write_optional_json(&input.opt_json)?; writer.context().pop(); writer.context().push("bytes", "Vec", "writing property"); writer.write_string("bytes")?; @@ -105,7 +105,7 @@ pub fn write_custom_type(input: &CustomType, writer: &mut W) -> Result writer.context().pop(); writer.context().push("optBytes", "Option>", "writing property"); writer.write_string("optBytes")?; - writer.write_nullable_bytes(&input.opt_bytes)?; + writer.write_optional_bytes(&input.opt_bytes)?; writer.context().pop(); writer.context().push("boolean", "bool", "writing property"); writer.write_string("boolean")?; @@ -113,7 +113,7 @@ pub fn write_custom_type(input: &CustomType, writer: &mut W) -> Result writer.context().pop(); writer.context().push("optBoolean", "Option", "writing property"); writer.write_string("optBoolean")?; - writer.write_nullable_bool(&input.opt_boolean)?; + writer.write_optional_bool(&input.opt_boolean)?; writer.context().pop(); writer.context().push("uArray", "Vec", "writing property"); writer.write_string("uArray")?; @@ -123,20 +123,20 @@ pub fn write_custom_type(input: &CustomType, writer: &mut W) -> Result writer.context().pop(); writer.context().push("uOptArray", "Option>", "writing property"); writer.write_string("uOptArray")?; - writer.write_nullable_array(&input.u_opt_array, |writer, item| { + writer.write_optional_array(&input.u_opt_array, |writer, item| { writer.write_u32(item) })?; writer.context().pop(); writer.context().push("optUOptArray", "Option>>", "writing property"); writer.write_string("optUOptArray")?; - writer.write_nullable_array(&input.opt_u_opt_array, |writer, item| { - writer.write_nullable_u32(item) + writer.write_optional_array(&input.opt_u_opt_array, |writer, item| { + writer.write_optional_u32(item) })?; writer.context().pop(); writer.context().push("optStrOptArray", "Option>>", "writing property"); writer.write_string("optStrOptArray")?; - writer.write_nullable_array(&input.opt_str_opt_array, |writer, item| { - writer.write_nullable_string(item) + writer.write_optional_array(&input.opt_str_opt_array, |writer, item| { + writer.write_optional_string(item) })?; writer.context().pop(); writer.context().push("uArrayArray", "Vec>", "writing property"); @@ -150,15 +150,15 @@ pub fn write_custom_type(input: &CustomType, writer: &mut W) -> Result writer.context().push("uOptArrayOptArray", "Vec>>>", "writing property"); writer.write_string("uOptArrayOptArray")?; writer.write_array(&input.u_opt_array_opt_array, |writer, item| { - writer.write_nullable_array(item, |writer, item| { - writer.write_nullable_u32(item) + writer.write_optional_array(item, |writer, item| { + writer.write_optional_u32(item) }) })?; writer.context().pop(); writer.context().push("uArrayOptArrayArray", "Vec>>>", "writing property"); writer.write_string("uArrayOptArrayArray")?; writer.write_array(&input.u_array_opt_array_array, |writer, item| { - writer.write_nullable_array(item, |writer, item| { + writer.write_optional_array(item, |writer, item| { writer.write_array(item, |writer, item| { writer.write_u32(item) }) @@ -167,10 +167,10 @@ pub fn write_custom_type(input: &CustomType, writer: &mut W) -> Result writer.context().pop(); writer.context().push("crazyArray", "Option>>>>>>", "writing property"); writer.write_string("crazyArray")?; - writer.write_nullable_array(&input.crazy_array, |writer, item| { - writer.write_nullable_array(item, |writer, item| { + writer.write_optional_array(&input.crazy_array, |writer, item| { + writer.write_optional_array(item, |writer, item| { writer.write_array(item, |writer, item| { - writer.write_nullable_array(item, |writer, item| { + writer.write_optional_array(item, |writer, item| { writer.write_u32(item) }) }) @@ -197,7 +197,7 @@ pub fn write_custom_type(input: &CustomType, writer: &mut W) -> Result writer.context().pop(); writer.context().push("optObjectArray", "Option>>", "writing property"); writer.write_string("optObjectArray")?; - writer.write_nullable_array(&input.opt_object_array, |writer, item| { + writer.write_optional_array(&input.opt_object_array, |writer, item| { if item.is_some() { AnotherType::write(item.as_ref().as_ref().unwrap(), writer) } else { @@ -211,7 +211,7 @@ pub fn write_custom_type(input: &CustomType, writer: &mut W) -> Result writer.context().pop(); writer.context().push("optEnum", "Option", "writing property"); writer.write_string("optEnum")?; - writer.write_nullable_i32(&input.opt_enum.map(|f| f as i32))?; + writer.write_optional_i32(&input.opt_enum.map(|f| f as i32))?; writer.context().pop(); writer.context().push("enumArray", "Vec", "writing property"); writer.write_string("enumArray")?; @@ -221,8 +221,8 @@ pub fn write_custom_type(input: &CustomType, writer: &mut W) -> Result writer.context().pop(); writer.context().push("optEnumArray", "Option>>", "writing property"); writer.write_string("optEnumArray")?; - writer.write_nullable_array(&input.opt_enum_array, |writer, item| { - writer.write_nullable_i32(&item.map(|f| f as i32)) + writer.write_optional_array(&input.opt_enum_array, |writer, item| { + writer.write_optional_i32(&item.map(|f| f as i32)) })?; writer.context().pop(); Ok(()) @@ -311,7 +311,7 @@ pub fn read_custom_type(reader: &mut R) -> Result { reader.context().push(&field, "Option", "type found, reading property"); - _opt_str = reader.read_nullable_string()?; + _opt_str = reader.read_optional_string()?; reader.context().pop(); } "u" => { @@ -322,7 +322,7 @@ pub fn read_custom_type(reader: &mut R) -> Result { reader.context().push(&field, "Option", "type found, reading property"); - _opt_u = reader.read_nullable_u32()?; + _opt_u = reader.read_optional_u32()?; reader.context().pop(); } "u8" => { @@ -375,7 +375,7 @@ pub fn read_custom_type(reader: &mut R) -> Result { reader.context().push(&field, "Option", "type found, reading property"); - _opt_bigint = reader.read_nullable_bigint()?; + _opt_bigint = reader.read_optional_bigint()?; reader.context().pop(); } "bignumber" => { @@ -386,7 +386,7 @@ pub fn read_custom_type(reader: &mut R) -> Result { reader.context().push(&field, "Option", "type found, reading property"); - _opt_bignumber = reader.read_nullable_bignumber()?; + _opt_bignumber = reader.read_optional_bignumber()?; reader.context().pop(); } "json" => { @@ -397,7 +397,7 @@ pub fn read_custom_type(reader: &mut R) -> Result { reader.context().push(&field, "Option", "type found, reading property"); - _opt_json = reader.read_nullable_json()?; + _opt_json = reader.read_optional_json()?; reader.context().pop(); } "bytes" => { @@ -408,7 +408,7 @@ pub fn read_custom_type(reader: &mut R) -> Result { reader.context().push(&field, "Option>", "type found, reading property"); - _opt_bytes = reader.read_nullable_bytes()?; + _opt_bytes = reader.read_optional_bytes()?; reader.context().pop(); } "boolean" => { @@ -419,7 +419,7 @@ pub fn read_custom_type(reader: &mut R) -> Result { reader.context().push(&field, "Option", "type found, reading property"); - _opt_boolean = reader.read_nullable_bool()?; + _opt_boolean = reader.read_optional_bool()?; reader.context().pop(); } "uArray" => { @@ -432,22 +432,22 @@ pub fn read_custom_type(reader: &mut R) -> Result { reader.context().push(&field, "Option>", "type found, reading property"); - _u_opt_array = reader.read_nullable_array(|reader| { + _u_opt_array = reader.read_optional_array(|reader| { reader.read_u32() })?; reader.context().pop(); } "optUOptArray" => { reader.context().push(&field, "Option>>", "type found, reading property"); - _opt_u_opt_array = reader.read_nullable_array(|reader| { - reader.read_nullable_u32() + _opt_u_opt_array = reader.read_optional_array(|reader| { + reader.read_optional_u32() })?; reader.context().pop(); } "optStrOptArray" => { reader.context().push(&field, "Option>>", "type found, reading property"); - _opt_str_opt_array = reader.read_nullable_array(|reader| { - reader.read_nullable_string() + _opt_str_opt_array = reader.read_optional_array(|reader| { + reader.read_optional_string() })?; reader.context().pop(); } @@ -464,8 +464,8 @@ pub fn read_custom_type(reader: &mut R) -> Result { reader.context().push(&field, "Vec>>>", "type found, reading property"); _u_opt_array_opt_array = reader.read_array(|reader| { - reader.read_nullable_array(|reader| { - reader.read_nullable_u32() + reader.read_optional_array(|reader| { + reader.read_optional_u32() }) })?; _u_opt_array_opt_array_set = true; @@ -474,7 +474,7 @@ pub fn read_custom_type(reader: &mut R) -> Result { reader.context().push(&field, "Vec>>>", "type found, reading property"); _u_array_opt_array_array = reader.read_array(|reader| { - reader.read_nullable_array(|reader| { + reader.read_optional_array(|reader| { reader.read_array(|reader| { reader.read_u32() }) @@ -485,10 +485,10 @@ pub fn read_custom_type(reader: &mut R) -> Result { reader.context().push(&field, "Option>>>>>>", "type found, reading property"); - _crazy_array = reader.read_nullable_array(|reader| { - reader.read_nullable_array(|reader| { + _crazy_array = reader.read_optional_array(|reader| { + reader.read_optional_array(|reader| { reader.read_array(|reader| { - reader.read_nullable_array(|reader| { + reader.read_optional_array(|reader| { reader.read_u32() }) }) @@ -525,7 +525,7 @@ pub fn read_custom_type(reader: &mut R) -> Result { reader.context().push(&field, "Option>>", "type found, reading property"); - _opt_object_array = reader.read_nullable_array(|reader| { + _opt_object_array = reader.read_optional_array(|reader| { let mut object: Option = None; if !reader.is_next_nil()? { object = Some(AnotherType::read(reader)?); @@ -582,7 +582,7 @@ pub fn read_custom_type(reader: &mut R) -> Result { reader.context().push(&field, "Option>>", "type found, reading property"); - _opt_enum_array = reader.read_nullable_array(|reader| { + _opt_enum_array = reader.read_optional_array(|reader| { let mut value: Option = None; if !reader.is_next_nil()? { if reader.is_next_string()? { diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_module/serialization.rs b/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_module/serialization.rs index 32a9e5a23b..40bf484236 100644 --- a/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_module/serialization.rs +++ b/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_module/serialization.rs @@ -53,7 +53,7 @@ pub fn write_imported_method_args(input: &InputImportedMethod, writer: writer.context().pop(); writer.context().push("optStr", "Option", "writing property"); writer.write_string("optStr")?; - writer.write_nullable_string(&input.opt_str)?; + writer.write_optional_string(&input.opt_str)?; writer.context().pop(); writer.context().push("u", "u32", "writing property"); writer.write_string("u")?; @@ -61,13 +61,13 @@ pub fn write_imported_method_args(input: &InputImportedMethod, writer: writer.context().pop(); writer.context().push("optU", "Option", "writing property"); writer.write_string("optU")?; - writer.write_nullable_u32(&input.opt_u)?; + writer.write_optional_u32(&input.opt_u)?; writer.context().pop(); writer.context().push("uArrayArray", "Vec>>>", "writing property"); writer.write_string("uArrayArray")?; writer.write_array(&input.u_array_array, |writer, item| { - writer.write_nullable_array(item, |writer, item| { - writer.write_nullable_u32(item) + writer.write_optional_array(item, |writer, item| { + writer.write_optional_u32(item) }) })?; writer.context().pop(); @@ -91,7 +91,7 @@ pub fn write_imported_method_args(input: &InputImportedMethod, writer: writer.context().pop(); writer.context().push("optObjectArray", "Option>>", "writing property"); writer.write_string("optObjectArray")?; - writer.write_nullable_array(&input.opt_object_array, |writer, item| { + writer.write_optional_array(&input.opt_object_array, |writer, item| { if item.is_some() { TestImportObject::write(item.as_ref().as_ref().unwrap(), writer) } else { @@ -105,7 +105,7 @@ pub fn write_imported_method_args(input: &InputImportedMethod, writer: writer.context().pop(); writer.context().push("optEnum", "Option", "writing property"); writer.write_string("optEnum")?; - writer.write_nullable_i32(&input.opt_enum.map(|f| f as i32))?; + writer.write_optional_i32(&input.opt_enum.map(|f| f as i32))?; writer.context().pop(); writer.context().push("enumArray", "Vec", "writing property"); writer.write_string("enumArray")?; @@ -115,8 +115,8 @@ pub fn write_imported_method_args(input: &InputImportedMethod, writer: writer.context().pop(); writer.context().push("optEnumArray", "Option>>", "writing property"); writer.write_string("optEnumArray")?; - writer.write_nullable_array(&input.opt_enum_array, |writer, item| { - writer.write_nullable_i32(&item.map(|f| f as i32)) + writer.write_optional_array(&input.opt_enum_array, |writer, item| { + writer.write_optional_i32(&item.map(|f| f as i32)) })?; writer.context().pop(); Ok(()) diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_object/serialization.rs b/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_object/serialization.rs index da0947cce0..bf3525604e 100644 --- a/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_object/serialization.rs +++ b/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_object/serialization.rs @@ -51,7 +51,7 @@ pub fn write_test_import_object(input: &TestImportObject, writer: &mut writer.context().pop(); writer.context().push("optObjectArray", "Option>>", "writing property"); writer.write_string("optObjectArray")?; - writer.write_nullable_array(&input.opt_object_array, |writer, item| { + writer.write_optional_array(&input.opt_object_array, |writer, item| { if item.is_some() { TestImportAnotherObject::write(item.as_ref().as_ref().unwrap(), writer) } else { @@ -65,7 +65,7 @@ pub fn write_test_import_object(input: &TestImportObject, writer: &mut writer.context().pop(); writer.context().push("optEnum", "Option", "writing property"); writer.write_string("optEnum")?; - writer.write_nullable_i32(&input.opt_enum.map(|f| f as i32))?; + writer.write_optional_i32(&input.opt_enum.map(|f| f as i32))?; writer.context().pop(); writer.context().push("enumArray", "Vec", "writing property"); writer.write_string("enumArray")?; @@ -75,8 +75,8 @@ pub fn write_test_import_object(input: &TestImportObject, writer: &mut writer.context().pop(); writer.context().push("optEnumArray", "Option>>", "writing property"); writer.write_string("optEnumArray")?; - writer.write_nullable_array(&input.opt_enum_array, |writer, item| { - writer.write_nullable_i32(&item.map(|f| f as i32)) + writer.write_optional_array(&input.opt_enum_array, |writer, item| { + writer.write_optional_i32(&item.map(|f| f as i32)) })?; writer.context().pop(); Ok(()) @@ -139,7 +139,7 @@ pub fn read_test_import_object(reader: &mut R) -> Result { reader.context().push(&field, "Option>>", "type found, reading property"); - _opt_object_array = reader.read_nullable_array(|reader| { + _opt_object_array = reader.read_optional_array(|reader| { let mut object: Option = None; if !reader.is_next_nil()? { object = Some(TestImportAnotherObject::read(reader)?); @@ -196,7 +196,7 @@ pub fn read_test_import_object(reader: &mut R) -> Result { reader.context().push(&field, "Option>>", "type found, reading property"); - _opt_enum_array = reader.read_nullable_array(|reader| { + _opt_enum_array = reader.read_optional_array(|reader| { let mut value: Option = None; if !reader.is_next_nil()? { if reader.is_next_string()? { diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-rs/module/serialization.rs b/packages/test-cases/cases/bind/sanity/output/wasm-rs/module/serialization.rs index 4aac4eaf93..b417ecf791 100644 --- a/packages/test-cases/cases/bind/sanity/output/wasm-rs/module/serialization.rs +++ b/packages/test-cases/cases/bind/sanity/output/wasm-rs/module/serialization.rs @@ -64,7 +64,7 @@ pub fn deserialize_module_method_args(input: &[u8]) -> Result { reader.context().push(&field, "Option", "type found, reading argument"); - _opt_str = reader.read_nullable_string()?; + _opt_str = reader.read_optional_string()?; reader.context().pop(); } "en" => { @@ -113,7 +113,7 @@ pub fn deserialize_module_method_args(input: &[u8]) -> Result { reader.context().push(&field, "Option>>", "type found, reading argument"); - _opt_enum_array = reader.read_nullable_array(|reader| { + _opt_enum_array = reader.read_optional_array(|reader| { let mut value: Option = None; if !reader.is_next_nil()? { if reader.is_next_string()? { @@ -237,7 +237,7 @@ pub fn deserialize_object_method_args(input: &[u8]) -> Result { reader.context().push(&field, "Option>>", "type found, reading argument"); - _opt_object_array = reader.read_nullable_array(|reader| { + _opt_object_array = reader.read_optional_array(|reader| { let mut object: Option = None; if !reader.is_next_nil()? { object = Some(AnotherType::read(reader)?); diff --git a/packages/wasm/as/assembly/__tests__/msgpack.spec.ts b/packages/wasm/as/assembly/__tests__/msgpack.spec.ts index e63ef0a802..b464b41c99 100644 --- a/packages/wasm/as/assembly/__tests__/msgpack.spec.ts +++ b/packages/wasm/as/assembly/__tests__/msgpack.spec.ts @@ -101,7 +101,7 @@ class Sanity { function serializeSanity(writer: Write, type: Sanity): void { writer.writeMapLength(23); writer.writeString("nil"); - writer.writeNullableString(type.nil); + writer.writeOptionalString(type.nil); writer.writeString("int8"); writer.writeInt8(type.int8); writer.writeString("int16"); @@ -117,9 +117,9 @@ function serializeSanity(writer: Write, type: Sanity): void { writer.writeString("boolean"); writer.writeBool(type.boolean); writer.writeString("optUint32"); - writer.writeNullableUInt32(type.optUint32); + writer.writeOptionalUInt32(type.optUint32); writer.writeString("optBool"); - writer.writeNullableBool(type.optBool); + writer.writeOptionalBool(type.optBool); writer.writeString("float32"); writer.writeFloat32(type.float32); writer.writeString("float64"); @@ -174,7 +174,7 @@ function deserializeSanity(reader: Read, type: Sanity): void { const field = reader.readString(); if (field == "nil") { - type.nil = reader.readNullableString(); + type.nil = reader.readOptionalString(); } else if (field == "int8") { type.int8 = reader.readInt8(); } else if (field == "int16") { @@ -190,9 +190,9 @@ function deserializeSanity(reader: Read, type: Sanity): void { } else if (field == "boolean") { type.boolean = reader.readBool(); } else if (field == "optUint32") { - type.optUint32 = reader.readNullableUInt32(); + type.optUint32 = reader.readOptionalUInt32(); } else if (field == "optBool") { - type.optBool = reader.readNullableBool(); + type.optBool = reader.readOptionalBool(); } else if (field == "float32") { type.float32 = reader.readFloat32(); } else if (field == "float64") { @@ -254,7 +254,7 @@ function deserializeWithOverflow(reader: Read, type: Sanity): void { const field = reader.readString(); if (field == "nil") { - type.nil = reader.readNullableString(); + type.nil = reader.readOptionalString(); } else if (field == "int8") { type.int8 = reader.readInt16(); } else if (field == "int16") { @@ -270,9 +270,9 @@ function deserializeWithOverflow(reader: Read, type: Sanity): void { } else if (field == "boolean") { type.boolean = reader.readBool(); } else if (field == "optUint32") { - type.optUint32 = reader.readNullableUInt32(); + type.optUint32 = reader.readOptionalUInt32(); } else if (field == "optBool") { - type.optBool = reader.readNullableBool(); + type.optBool = reader.readOptionalBool(); } else if (field == "float32") { type.float32 = reader.readFloat64(); } else if (field == "float64") { @@ -320,7 +320,7 @@ function deserializeWithInvalidTypes(reader: Read, type: Sanity): void { const field = reader.readString(); if (field == "nil") { - type.nil = reader.readNullableString(); + type.nil = reader.readOptionalString(); } else if (field == "int8") { type.str = reader.readString(); } else if (field == "int8") { @@ -338,9 +338,9 @@ function deserializeWithInvalidTypes(reader: Read, type: Sanity): void { } else if (field == "boolean") { type.boolean = reader.readBool(); } else if (field == "optUint32") { - type.optUint32 = reader.readNullableUInt32(); + type.optUint32 = reader.readOptionalUInt32(); } else if (field == "optBool") { - type.optBool = reader.readNullableBool(); + type.optBool = reader.readOptionalBool(); } else if (field == "float32") { type.float32 = reader.readFloat32(); } else if (field == "float64") { diff --git a/packages/wasm/as/assembly/msgpack/Read.ts b/packages/wasm/as/assembly/msgpack/Read.ts index 317623afbc..6237209a0e 100644 --- a/packages/wasm/as/assembly/msgpack/Read.ts +++ b/packages/wasm/as/assembly/msgpack/Read.ts @@ -33,26 +33,26 @@ export abstract class Read { value_fn: (reader: Read) => V ): Map; - abstract readNullableBool(): Option; - abstract readNullableInt8(): Option; - abstract readNullableInt16(): Option; - abstract readNullableInt32(): Option; - abstract readNullableUInt8(): Option; - abstract readNullableUInt16(): Option; - abstract readNullableUInt32(): Option; - abstract readNullableFloat32(): Option; - abstract readNullableFloat64(): Option; - abstract readNullableString(): string | null; - abstract readNullableBytes(): ArrayBuffer | null; - abstract readNullableBigInt(): BigInt | null; - abstract readNullableBigNumber(): BigNumber | null; - abstract readNullableJSON(): JSON.Value | null; - abstract readNullableArray(fn: (decoder: Read) => T): Array | null; - abstract readNullableMap( + abstract readOptionalBool(): Option; + abstract readOptionalInt8(): Option; + abstract readOptionalInt16(): Option; + abstract readOptionalInt32(): Option; + abstract readOptionalUInt8(): Option; + abstract readOptionalUInt16(): Option; + abstract readOptionalUInt32(): Option; + abstract readOptionalFloat32(): Option; + abstract readOptionalFloat64(): Option; + abstract readOptionalString(): string | null; + abstract readOptionalBytes(): ArrayBuffer | null; + abstract readOptionalBigInt(): BigInt | null; + abstract readOptionalBigNumber(): BigNumber | null; + abstract readOptionalJSON(): JSON.Value | null; + abstract readOptionalArray(fn: (decoder: Read) => T): Array | null; + abstract readOptionalMap( key_fn: (reader: Read) => K, value_fn: (reader: Read) => V ): Map | null; - abstract readNullableExtGenericMap( + abstract readOptionalExtGenericMap( key_fn: (reader: Read) => K, value_fn: (reader: Read) => V ): Map | null; diff --git a/packages/wasm/as/assembly/msgpack/ReadDecoder.ts b/packages/wasm/as/assembly/msgpack/ReadDecoder.ts index 3a902eb81e..81587721cf 100644 --- a/packages/wasm/as/assembly/msgpack/ReadDecoder.ts +++ b/packages/wasm/as/assembly/msgpack/ReadDecoder.ts @@ -364,98 +364,98 @@ export class ReadDecoder extends Read { return this.readMap(key_fn, value_fn); } - readNullableBool(): Option { + readOptionalBool(): Option { if (this.isNextNil()) { return Option.None(); } return Option.Some(this.readBool()); } - readNullableInt8(): Option { + readOptionalInt8(): Option { if (this.isNextNil()) { return Option.None(); } return Option.Some(this.readInt8()); } - readNullableInt16(): Option { + readOptionalInt16(): Option { if (this.isNextNil()) { return Option.None(); } return Option.Some(this.readInt16()); } - readNullableInt32(): Option { + readOptionalInt32(): Option { if (this.isNextNil()) { return Option.None(); } return Option.Some(this.readInt32()); } - readNullableUInt8(): Option { + readOptionalUInt8(): Option { if (this.isNextNil()) { return Option.None(); } return Option.Some(this.readUInt8()); } - readNullableUInt16(): Option { + readOptionalUInt16(): Option { if (this.isNextNil()) { return Option.None(); } return Option.Some(this.readUInt16()); } - readNullableUInt32(): Option { + readOptionalUInt32(): Option { if (this.isNextNil()) { return Option.None(); } return Option.Some(this.readUInt32()); } - readNullableFloat32(): Option { + readOptionalFloat32(): Option { if (this.isNextNil()) { return Option.None(); } return Option.Some(this.readFloat32()); } - readNullableFloat64(): Option { + readOptionalFloat64(): Option { if (this.isNextNil()) { return Option.None(); } return Option.Some(this.readFloat64()); } - readNullableString(): string | null { + readOptionalString(): string | null { if (this.isNextNil()) { return null; } return this.readString(); } - readNullableBytes(): ArrayBuffer | null { + readOptionalBytes(): ArrayBuffer | null { if (this.isNextNil()) { return null; } return this.readBytes(); } - readNullableBigInt(): BigInt | null { + readOptionalBigInt(): BigInt | null { if (this.isNextNil()) { return null; } return this.readBigInt(); } - readNullableBigNumber(): BigNumber | null { + readOptionalBigNumber(): BigNumber | null { if (this.isNextNil()) { return null; } return this.readBigNumber(); } - readNullableJSON(): JSON.Value | null { + readOptionalJSON(): JSON.Value | null { if (this.isNextNil()) { return null; } @@ -463,14 +463,14 @@ export class ReadDecoder extends Read { return this.readJSON(); } - readNullableArray(fn: (decoder: Read) => T): Array | null { + readOptionalArray(fn: (decoder: Read) => T): Array | null { if (this.isNextNil()) { return null; } return this.readArray(fn); } - readNullableMap( + readOptionalMap( key_fn: (decoder: Read) => K, value_fn: (decoder: Read) => V ): Map | null { @@ -480,7 +480,7 @@ export class ReadDecoder extends Read { return this.readMap(key_fn, value_fn); } - readNullableExtGenericMap( + readOptionalExtGenericMap( key_fn: (decoder: Read) => K, value_fn: (decoder: Read) => V ): Map | null { diff --git a/packages/wasm/as/assembly/msgpack/Write.ts b/packages/wasm/as/assembly/msgpack/Write.ts index f7ff982686..2292e6e2ba 100644 --- a/packages/wasm/as/assembly/msgpack/Write.ts +++ b/packages/wasm/as/assembly/msgpack/Write.ts @@ -39,30 +39,30 @@ export abstract class Write { value_fn: (writer: Write, value: V) => void ): void; - abstract writeNullableBool(value: Option): void; - abstract writeNullableInt8(value: Option): void; - abstract writeNullableInt16(value: Option): void; - abstract writeNullableInt32(value: Option): void; - abstract writeNullableUInt8(value: Option): void; - abstract writeNullableUInt16(value: Option): void; - abstract writeNullableUInt32(value: Option): void; - abstract writeNullableFloat32(value: Option): void; - abstract writeNullableFloat64(value: Option): void; - abstract writeNullableString(value: string | null): void; - abstract writeNullableBytes(value: ArrayBuffer | null): void; - abstract writeNullableBigInt(value: BigInt | null): void; - abstract writeNullableBigNumber(value: BigNumber | null): void; - abstract writeNullableJSON(value: JSON.Value | null): void; - abstract writeNullableArray( + abstract writeOptionalBool(value: Option): void; + abstract writeOptionalInt8(value: Option): void; + abstract writeOptionalInt16(value: Option): void; + abstract writeOptionalInt32(value: Option): void; + abstract writeOptionalUInt8(value: Option): void; + abstract writeOptionalUInt16(value: Option): void; + abstract writeOptionalUInt32(value: Option): void; + abstract writeOptionalFloat32(value: Option): void; + abstract writeOptionalFloat64(value: Option): void; + abstract writeOptionalString(value: string | null): void; + abstract writeOptionalBytes(value: ArrayBuffer | null): void; + abstract writeOptionalBigInt(value: BigInt | null): void; + abstract writeOptionalBigNumber(value: BigNumber | null): void; + abstract writeOptionalJSON(value: JSON.Value | null): void; + abstract writeOptionalArray( a: Array | null, fn: (writer: Write, item: T) => void ): void; - abstract writeNullableMap( + abstract writeOptionalMap( m: Map | null, key_fn: (writer: Write, key: K) => void, value_fn: (writer: Write, value: V) => void ): void; - abstract writeNullableExtGenericMap( + abstract writeOptionalExtGenericMap( m: Map, key_fn: (writer: Write, key: K) => void, value_fn: (writer: Write, value: V) => void diff --git a/packages/wasm/as/assembly/msgpack/WriteEncoder.ts b/packages/wasm/as/assembly/msgpack/WriteEncoder.ts index 02140973b5..06a561ae00 100644 --- a/packages/wasm/as/assembly/msgpack/WriteEncoder.ts +++ b/packages/wasm/as/assembly/msgpack/WriteEncoder.ts @@ -235,7 +235,7 @@ export class WriteEncoder extends Write { this.writeMap(m, key_fn, value_fn); } - writeNullableBool(value: Option): void { + writeOptionalBool(value: Option): void { if (value.isNone) { this.writeNil(); return; @@ -244,7 +244,7 @@ export class WriteEncoder extends Write { this.writeBool(value.unwrap()); } - writeNullableInt8(value: Option): void { + writeOptionalInt8(value: Option): void { if (value.isNone) { this.writeNil(); return; @@ -253,7 +253,7 @@ export class WriteEncoder extends Write { this.writeInt8(value.unwrap()); } - writeNullableInt16(value: Option): void { + writeOptionalInt16(value: Option): void { if (value.isNone) { this.writeNil(); return; @@ -262,7 +262,7 @@ export class WriteEncoder extends Write { this.writeInt16(value.unwrap()); } - writeNullableInt32(value: Option): void { + writeOptionalInt32(value: Option): void { if (value.isNone) { this.writeNil(); return; @@ -271,7 +271,7 @@ export class WriteEncoder extends Write { this.writeInt32(value.unwrap()); } - writeNullableUInt8(value: Option): void { + writeOptionalUInt8(value: Option): void { if (value.isNone) { this.writeNil(); return; @@ -280,7 +280,7 @@ export class WriteEncoder extends Write { this.writeUInt8(value.unwrap()); } - writeNullableUInt16(value: Option): void { + writeOptionalUInt16(value: Option): void { if (value.isNone) { this.writeNil(); return; @@ -289,7 +289,7 @@ export class WriteEncoder extends Write { this.writeUInt16(value.unwrap()); } - writeNullableUInt32(value: Option): void { + writeOptionalUInt32(value: Option): void { if (value.isNone) { this.writeNil(); return; @@ -298,7 +298,7 @@ export class WriteEncoder extends Write { this.writeUInt32(value.unwrap()); } - writeNullableFloat32(value: Option): void { + writeOptionalFloat32(value: Option): void { if (value.isNone) { this.writeNil(); return; @@ -307,7 +307,7 @@ export class WriteEncoder extends Write { this.writeFloat32(value.unwrap()); } - writeNullableFloat64(value: Option): void { + writeOptionalFloat64(value: Option): void { if (value.isNone) { this.writeNil(); return; @@ -316,7 +316,7 @@ export class WriteEncoder extends Write { this.writeFloat64(value.unwrap()); } - writeNullableString(value: string | null): void { + writeOptionalString(value: string | null): void { if (value === null) { this.writeNil(); return; @@ -325,7 +325,7 @@ export class WriteEncoder extends Write { this.writeString(value); } - writeNullableBytes(value: ArrayBuffer | null): void { + writeOptionalBytes(value: ArrayBuffer | null): void { if (value === null) { this.writeNil(); return; @@ -334,7 +334,7 @@ export class WriteEncoder extends Write { this.writeBytes(value); } - writeNullableBigInt(value: BigInt | null): void { + writeOptionalBigInt(value: BigInt | null): void { if (value === null) { this.writeNil(); return; @@ -343,7 +343,7 @@ export class WriteEncoder extends Write { this.writeBigInt(value); } - writeNullableBigNumber(value: BigNumber): void { + writeOptionalBigNumber(value: BigNumber): void { if (value === null) { this.writeNil(); return; @@ -352,7 +352,7 @@ export class WriteEncoder extends Write { this.writeBigNumber(value); } - writeNullableJSON(value: JSON.Value | null): void { + writeOptionalJSON(value: JSON.Value | null): void { if (value === null) { this.writeNil(); return; @@ -361,7 +361,7 @@ export class WriteEncoder extends Write { this.writeJSON(value); } - writeNullableArray( + writeOptionalArray( a: Array | null, fn: (encoder: Write, item: T) => void ): void { @@ -372,7 +372,7 @@ export class WriteEncoder extends Write { this.writeArray(a, fn); } - writeNullableMap( + writeOptionalMap( m: Map | null, key_fn: (encoder: Write, key: K) => void, value_fn: (encoder: Write, value: V) => void @@ -384,7 +384,7 @@ export class WriteEncoder extends Write { this.writeMap(m, key_fn, value_fn); } - writeNullableExtGenericMap( + writeOptionalExtGenericMap( m: Map | null, key_fn: (encoder: Write, key: K) => void, value_fn: (encoder: Write, value: V) => void diff --git a/packages/wasm/as/assembly/msgpack/WriteSizer.ts b/packages/wasm/as/assembly/msgpack/WriteSizer.ts index 4b32fd07c9..05d789c3a5 100644 --- a/packages/wasm/as/assembly/msgpack/WriteSizer.ts +++ b/packages/wasm/as/assembly/msgpack/WriteSizer.ts @@ -195,7 +195,7 @@ export class WriteSizer extends Write { this.extByteLengths.push(byteLength); } - writeNullableBool(value: Option): void { + writeOptionalBool(value: Option): void { if (value.isNone) { this.writeNil(); return; @@ -204,7 +204,7 @@ export class WriteSizer extends Write { this.writeBool(value.unwrap()); } - writeNullableInt8(value: Option): void { + writeOptionalInt8(value: Option): void { if (value.isNone) { this.writeNil(); return; @@ -213,7 +213,7 @@ export class WriteSizer extends Write { this.writeInt8(value.unwrap()); } - writeNullableInt16(value: Option): void { + writeOptionalInt16(value: Option): void { if (value.isNone) { this.writeNil(); return; @@ -222,7 +222,7 @@ export class WriteSizer extends Write { this.writeInt16(value.unwrap()); } - writeNullableInt32(value: Option): void { + writeOptionalInt32(value: Option): void { if (value.isNone) { this.writeNil(); return; @@ -231,7 +231,7 @@ export class WriteSizer extends Write { this.writeInt32(value.unwrap()); } - writeNullableUInt8(value: Option): void { + writeOptionalUInt8(value: Option): void { if (value.isNone) { this.writeNil(); return; @@ -240,7 +240,7 @@ export class WriteSizer extends Write { this.writeUInt8(value.unwrap()); } - writeNullableUInt16(value: Option): void { + writeOptionalUInt16(value: Option): void { if (value.isNone) { this.writeNil(); return; @@ -249,7 +249,7 @@ export class WriteSizer extends Write { this.writeUInt16(value.unwrap()); } - writeNullableUInt32(value: Option): void { + writeOptionalUInt32(value: Option): void { if (value.isNone) { this.writeNil(); return; @@ -258,7 +258,7 @@ export class WriteSizer extends Write { this.writeUInt32(value.unwrap()); } - writeNullableFloat32(value: Option): void { + writeOptionalFloat32(value: Option): void { if (value.isNone) { this.writeNil(); return; @@ -267,7 +267,7 @@ export class WriteSizer extends Write { this.writeFloat32(value.unwrap()); } - writeNullableFloat64(value: Option): void { + writeOptionalFloat64(value: Option): void { if (value.isNone) { this.writeNil(); return; @@ -276,7 +276,7 @@ export class WriteSizer extends Write { this.writeFloat64(value.unwrap()); } - writeNullableString(value: string | null): void { + writeOptionalString(value: string | null): void { if (value === null) { this.writeNil(); return; @@ -285,7 +285,7 @@ export class WriteSizer extends Write { this.writeString(value); } - writeNullableBytes(value: ArrayBuffer | null): void { + writeOptionalBytes(value: ArrayBuffer | null): void { if (value === null) { this.writeNil(); return; @@ -294,7 +294,7 @@ export class WriteSizer extends Write { this.writeBytes(value); } - writeNullableBigInt(value: BigInt | null): void { + writeOptionalBigInt(value: BigInt | null): void { if (value === null) { this.writeNil(); return; @@ -303,7 +303,7 @@ export class WriteSizer extends Write { this.writeBigInt(value); } - writeNullableBigNumber(value: BigNumber): void { + writeOptionalBigNumber(value: BigNumber): void { if (value === null) { this.writeNil(); return; @@ -312,7 +312,7 @@ export class WriteSizer extends Write { this.writeBigNumber(value); } - writeNullableJSON(value: JSON.Value | null): void { + writeOptionalJSON(value: JSON.Value | null): void { if (value === null) { this.writeNil(); return; @@ -321,7 +321,7 @@ export class WriteSizer extends Write { this.writeJSON(value); } - writeNullableArray( + writeOptionalArray( a: Array | null, fn: (sizer: Write, item: T) => void ): void { @@ -333,7 +333,7 @@ export class WriteSizer extends Write { this.writeArray(a, fn); } - writeNullableMap( + writeOptionalMap( m: Map | null, key_fn: (sizer: Write, key: K) => void, value_fn: (sizer: Write, value: V) => void @@ -346,7 +346,7 @@ export class WriteSizer extends Write { this.writeMap(m, key_fn, value_fn); } - writeNullableExtGenericMap( + writeOptionalExtGenericMap( m: Map | null, key_fn: (sizer: Write, key: K) => void, value_fn: (sizer: Write, value: V) => void diff --git a/packages/wasm/rs/src/msgpack/read.rs b/packages/wasm/rs/src/msgpack/read.rs index 7ace1eda36..26446193d9 100644 --- a/packages/wasm/rs/src/msgpack/read.rs +++ b/packages/wasm/rs/src/msgpack/read.rs @@ -41,32 +41,32 @@ pub trait Read { where K: Eq + Hash + Ord; - fn read_nullable_bool(&mut self) -> Result, DecodeError>; - fn read_nullable_i8(&mut self) -> Result, DecodeError>; - fn read_nullable_i16(&mut self) -> Result, DecodeError>; - fn read_nullable_i32(&mut self) -> Result, DecodeError>; - fn read_nullable_u8(&mut self) -> Result, DecodeError>; - fn read_nullable_u16(&mut self) -> Result, DecodeError>; - fn read_nullable_u32(&mut self) -> Result, DecodeError>; - fn read_nullable_f32(&mut self) -> Result, DecodeError>; - fn read_nullable_f64(&mut self) -> Result, DecodeError>; - fn read_nullable_string(&mut self) -> Result, DecodeError>; - fn read_nullable_bytes(&mut self) -> Result>, DecodeError>; - fn read_nullable_bigint(&mut self) -> Result, DecodeError>; - fn read_nullable_bignumber(&mut self) -> Result, DecodeError>; - fn read_nullable_json(&mut self) -> Result, DecodeError>; - fn read_nullable_array( + fn read_optional_bool(&mut self) -> Result, DecodeError>; + fn read_optional_i8(&mut self) -> Result, DecodeError>; + fn read_optional_i16(&mut self) -> Result, DecodeError>; + fn read_optional_i32(&mut self) -> Result, DecodeError>; + fn read_optional_u8(&mut self) -> Result, DecodeError>; + fn read_optional_u16(&mut self) -> Result, DecodeError>; + fn read_optional_u32(&mut self) -> Result, DecodeError>; + fn read_optional_f32(&mut self) -> Result, DecodeError>; + fn read_optional_f64(&mut self) -> Result, DecodeError>; + fn read_optional_string(&mut self) -> Result, DecodeError>; + fn read_optional_bytes(&mut self) -> Result>, DecodeError>; + fn read_optional_bigint(&mut self) -> Result, DecodeError>; + fn read_optional_bignumber(&mut self) -> Result, DecodeError>; + fn read_optional_json(&mut self) -> Result, DecodeError>; + fn read_optional_array( &mut self, item_reader: impl FnMut(&mut Self) -> Result, ) -> Result>, DecodeError>; - fn read_nullable_map( + fn read_optional_map( &mut self, key_reader: impl FnMut(&mut Self) -> Result, val_reader: impl FnMut(&mut Self) -> Result, ) -> Result>, DecodeError> where K: Eq + Hash + Ord; - fn read_nullable_ext_generic_map( + fn read_optional_ext_generic_map( &mut self, key_reader: impl FnMut(&mut Self) -> Result, val_reader: impl FnMut(&mut Self) -> Result, diff --git a/packages/wasm/rs/src/msgpack/read_decoder.rs b/packages/wasm/rs/src/msgpack/read_decoder.rs index f96324be9a..169eeb694b 100644 --- a/packages/wasm/rs/src/msgpack/read_decoder.rs +++ b/packages/wasm/rs/src/msgpack/read_decoder.rs @@ -497,7 +497,7 @@ impl Read for ReadDecoder { self.read_map(key_reader, val_reader) } - fn read_nullable_bool(&mut self) -> Result, DecodeError> { + fn read_optional_bool(&mut self) -> Result, DecodeError> { if self.is_next_nil()? { Ok(None) } else { @@ -508,7 +508,7 @@ impl Read for ReadDecoder { } } - fn read_nullable_i8(&mut self) -> Result, DecodeError> { + fn read_optional_i8(&mut self) -> Result, DecodeError> { if self.is_next_nil()? { Ok(None) } else { @@ -519,7 +519,7 @@ impl Read for ReadDecoder { } } - fn read_nullable_i16(&mut self) -> Result, DecodeError> { + fn read_optional_i16(&mut self) -> Result, DecodeError> { if self.is_next_nil()? { Ok(None) } else { @@ -530,7 +530,7 @@ impl Read for ReadDecoder { } } - fn read_nullable_i32(&mut self) -> Result, DecodeError> { + fn read_optional_i32(&mut self) -> Result, DecodeError> { if self.is_next_nil()? { Ok(None) } else { @@ -541,7 +541,7 @@ impl Read for ReadDecoder { } } - fn read_nullable_u8(&mut self) -> Result, DecodeError> { + fn read_optional_u8(&mut self) -> Result, DecodeError> { if self.is_next_nil()? { Ok(None) } else { @@ -552,7 +552,7 @@ impl Read for ReadDecoder { } } - fn read_nullable_u16(&mut self) -> Result, DecodeError> { + fn read_optional_u16(&mut self) -> Result, DecodeError> { if self.is_next_nil()? { Ok(None) } else { @@ -563,7 +563,7 @@ impl Read for ReadDecoder { } } - fn read_nullable_u32(&mut self) -> Result, DecodeError> { + fn read_optional_u32(&mut self) -> Result, DecodeError> { if self.is_next_nil()? { Ok(None) } else { @@ -574,7 +574,7 @@ impl Read for ReadDecoder { } } - fn read_nullable_f32(&mut self) -> Result, DecodeError> { + fn read_optional_f32(&mut self) -> Result, DecodeError> { if self.is_next_nil()? { Ok(None) } else { @@ -585,7 +585,7 @@ impl Read for ReadDecoder { } } - fn read_nullable_f64(&mut self) -> Result, DecodeError> { + fn read_optional_f64(&mut self) -> Result, DecodeError> { if self.is_next_nil()? { Ok(None) } else { @@ -596,7 +596,7 @@ impl Read for ReadDecoder { } } - fn read_nullable_string(&mut self) -> Result, DecodeError> { + fn read_optional_string(&mut self) -> Result, DecodeError> { if self.is_next_nil()? { Ok(None) } else { @@ -607,7 +607,7 @@ impl Read for ReadDecoder { } } - fn read_nullable_bytes(&mut self) -> Result>, DecodeError> { + fn read_optional_bytes(&mut self) -> Result>, DecodeError> { if self.is_next_nil()? { Ok(None) } else { @@ -618,7 +618,7 @@ impl Read for ReadDecoder { } } - fn read_nullable_bigint(&mut self) -> Result, DecodeError> { + fn read_optional_bigint(&mut self) -> Result, DecodeError> { if self.is_next_nil()? { Ok(None) } else { @@ -629,7 +629,7 @@ impl Read for ReadDecoder { } } - fn read_nullable_bignumber(&mut self) -> Result, DecodeError> { + fn read_optional_bignumber(&mut self) -> Result, DecodeError> { if self.is_next_nil()? { Ok(None) } else { @@ -640,7 +640,7 @@ impl Read for ReadDecoder { } } - fn read_nullable_json(&mut self) -> Result, DecodeError> { + fn read_optional_json(&mut self) -> Result, DecodeError> { if self.is_next_nil()? { Ok(None) } else { @@ -651,7 +651,7 @@ impl Read for ReadDecoder { } } - fn read_nullable_array( + fn read_optional_array( &mut self, item_reader: impl FnMut(&mut Self) -> Result, ) -> Result>, DecodeError> { @@ -665,7 +665,7 @@ impl Read for ReadDecoder { } } - fn read_nullable_map( + fn read_optional_map( &mut self, key_reader: impl FnMut(&mut Self) -> Result, val_reader: impl FnMut(&mut Self) -> Result, @@ -683,7 +683,7 @@ impl Read for ReadDecoder { } } - fn read_nullable_ext_generic_map( + fn read_optional_ext_generic_map( &mut self, key_reader: impl FnMut(&mut Self) -> Result, val_reader: impl FnMut(&mut Self) -> Result, diff --git a/packages/wasm/rs/src/msgpack/write.rs b/packages/wasm/rs/src/msgpack/write.rs index e7e51bf1ba..4119c8646e 100644 --- a/packages/wasm/rs/src/msgpack/write.rs +++ b/packages/wasm/rs/src/msgpack/write.rs @@ -45,26 +45,26 @@ pub trait Write { where K: Clone + Eq + Hash + Ord; - fn write_nullable_bool(&mut self, value: &Option) -> Result<(), EncodeError>; - fn write_nullable_i8(&mut self, value: &Option) -> Result<(), EncodeError>; - fn write_nullable_i16(&mut self, value: &Option) -> Result<(), EncodeError>; - fn write_nullable_i32(&mut self, value: &Option) -> Result<(), EncodeError>; - fn write_nullable_u8(&mut self, value: &Option) -> Result<(), EncodeError>; - fn write_nullable_u16(&mut self, value: &Option) -> Result<(), EncodeError>; - fn write_nullable_u32(&mut self, value: &Option) -> Result<(), EncodeError>; - fn write_nullable_f32(&mut self, value: &Option) -> Result<(), EncodeError>; - fn write_nullable_f64(&mut self, value: &Option) -> Result<(), EncodeError>; - fn write_nullable_string(&mut self, value: &Option) -> Result<(), EncodeError>; - fn write_nullable_bytes(&mut self, value: &Option>) -> Result<(), EncodeError>; - fn write_nullable_bigint(&mut self, value: &Option) -> Result<(), EncodeError>; - fn write_nullable_bignumber(&mut self, value: &Option) -> Result<(), EncodeError>; - fn write_nullable_json(&mut self, value: &Option) -> Result<(), EncodeError>; - fn write_nullable_array( + fn write_optional_bool(&mut self, value: &Option) -> Result<(), EncodeError>; + fn write_optional_i8(&mut self, value: &Option) -> Result<(), EncodeError>; + fn write_optional_i16(&mut self, value: &Option) -> Result<(), EncodeError>; + fn write_optional_i32(&mut self, value: &Option) -> Result<(), EncodeError>; + fn write_optional_u8(&mut self, value: &Option) -> Result<(), EncodeError>; + fn write_optional_u16(&mut self, value: &Option) -> Result<(), EncodeError>; + fn write_optional_u32(&mut self, value: &Option) -> Result<(), EncodeError>; + fn write_optional_f32(&mut self, value: &Option) -> Result<(), EncodeError>; + fn write_optional_f64(&mut self, value: &Option) -> Result<(), EncodeError>; + fn write_optional_string(&mut self, value: &Option) -> Result<(), EncodeError>; + fn write_optional_bytes(&mut self, value: &Option>) -> Result<(), EncodeError>; + fn write_optional_bigint(&mut self, value: &Option) -> Result<(), EncodeError>; + fn write_optional_bignumber(&mut self, value: &Option) -> Result<(), EncodeError>; + fn write_optional_json(&mut self, value: &Option) -> Result<(), EncodeError>; + fn write_optional_array( &mut self, opt_array: &Option>, item_writer: impl FnMut(&mut Self, &T) -> Result<(), EncodeError>, ) -> Result<(), EncodeError>; - fn write_nullable_map( + fn write_optional_map( &mut self, opt_map: &Option>, key_writer: impl FnMut(&mut Self, &K) -> Result<(), EncodeError>, @@ -72,7 +72,7 @@ pub trait Write { ) -> Result<(), EncodeError> where K: Clone + Eq + Hash + Ord; - fn write_nullable_ext_generic_map( + fn write_optional_ext_generic_map( &mut self, opt_map: &Option>, key_writer: impl FnMut(&mut Self, &K) -> Result<(), EncodeError>, diff --git a/packages/wasm/rs/src/msgpack/write_encoder.rs b/packages/wasm/rs/src/msgpack/write_encoder.rs index 3acba4afed..74531eb073 100644 --- a/packages/wasm/rs/src/msgpack/write_encoder.rs +++ b/packages/wasm/rs/src/msgpack/write_encoder.rs @@ -308,105 +308,105 @@ impl Write for WriteEncoder { Ok(()) } - fn write_nullable_bool(&mut self, value: &Option) -> Result<(), EncodeError> { + fn write_optional_bool(&mut self, value: &Option) -> Result<(), EncodeError> { match value { None => Write::write_nil(self), Some(v) => Write::write_bool(self, v), } } - fn write_nullable_i8(&mut self, value: &Option) -> Result<(), EncodeError> { + fn write_optional_i8(&mut self, value: &Option) -> Result<(), EncodeError> { match value { None => Write::write_nil(self), Some(v) => Write::write_i8(self, v), } } - fn write_nullable_i16(&mut self, value: &Option) -> Result<(), EncodeError> { + fn write_optional_i16(&mut self, value: &Option) -> Result<(), EncodeError> { match value { None => Write::write_nil(self), Some(v) => Write::write_i16(self, v), } } - fn write_nullable_i32(&mut self, value: &Option) -> Result<(), EncodeError> { + fn write_optional_i32(&mut self, value: &Option) -> Result<(), EncodeError> { match value { None => Write::write_nil(self), Some(v) => Write::write_i32(self, v), } } - fn write_nullable_u8(&mut self, value: &Option) -> Result<(), EncodeError> { + fn write_optional_u8(&mut self, value: &Option) -> Result<(), EncodeError> { match value { None => Write::write_nil(self), Some(v) => Write::write_u8(self, v), } } - fn write_nullable_u16(&mut self, value: &Option) -> Result<(), EncodeError> { + fn write_optional_u16(&mut self, value: &Option) -> Result<(), EncodeError> { match value { None => Write::write_nil(self), Some(v) => Write::write_u16(self, v), } } - fn write_nullable_u32(&mut self, value: &Option) -> Result<(), EncodeError> { + fn write_optional_u32(&mut self, value: &Option) -> Result<(), EncodeError> { match value { None => Write::write_nil(self), Some(v) => Write::write_u32(self, v), } } - fn write_nullable_f32(&mut self, value: &Option) -> Result<(), EncodeError> { + fn write_optional_f32(&mut self, value: &Option) -> Result<(), EncodeError> { match value { None => Write::write_nil(self), Some(v) => Write::write_f32(self, v), } } - fn write_nullable_f64(&mut self, value: &Option) -> Result<(), EncodeError> { + fn write_optional_f64(&mut self, value: &Option) -> Result<(), EncodeError> { match value { None => Write::write_nil(self), Some(v) => Write::write_f64(self, v), } } - fn write_nullable_string(&mut self, value: &Option) -> Result<(), EncodeError> { + fn write_optional_string(&mut self, value: &Option) -> Result<(), EncodeError> { match value { None => Write::write_nil(self), Some(s) => Write::write_string(self, s), } } - fn write_nullable_bytes(&mut self, value: &Option>) -> Result<(), EncodeError> { + fn write_optional_bytes(&mut self, value: &Option>) -> Result<(), EncodeError> { match value { None => Write::write_nil(self), Some(bytes) => Write::write_bytes(self, bytes), } } - fn write_nullable_bigint(&mut self, value: &Option) -> Result<(), EncodeError> { + fn write_optional_bigint(&mut self, value: &Option) -> Result<(), EncodeError> { match value { None => Write::write_nil(self), Some(bigint) => Write::write_bigint(self, bigint), } } - fn write_nullable_bignumber(&mut self, value: &Option) -> Result<(), EncodeError> { + fn write_optional_bignumber(&mut self, value: &Option) -> Result<(), EncodeError> { match value { None => Write::write_nil(self), Some(bignumber) => Write::write_bignumber(self, bignumber) } } - fn write_nullable_json(&mut self, value: &Option) -> Result<(), EncodeError> { + fn write_optional_json(&mut self, value: &Option) -> Result<(), EncodeError> { match value { None => Write::write_nil(self), Some(json) => Write::write_json(self, json), } } - fn write_nullable_array( + fn write_optional_array( &mut self, opt_array: &Option>, item_writer: impl FnMut(&mut Self, &T) -> Result<(), EncodeError>, @@ -417,7 +417,7 @@ impl Write for WriteEncoder { } } - fn write_nullable_map( + fn write_optional_map( &mut self, opt_map: &Option>, key_writer: impl FnMut(&mut Self, &K) -> Result<(), EncodeError>, @@ -432,7 +432,7 @@ impl Write for WriteEncoder { } } - fn write_nullable_ext_generic_map( + fn write_optional_ext_generic_map( &mut self, opt_map: &Option>, key_writer: impl FnMut(&mut Self, &K) -> Result<(), EncodeError>, diff --git a/packages/wasm/rs/tests/msgpack_spec.rs b/packages/wasm/rs/tests/msgpack_spec.rs index 6b4037e179..c6995c5072 100644 --- a/packages/wasm/rs/tests/msgpack_spec.rs +++ b/packages/wasm/rs/tests/msgpack_spec.rs @@ -91,9 +91,9 @@ fn serialize_sanity(writer: &mut W, sanity: &mut Sanity) -> Result<(), writer.write_string("boolean")?; writer.write_bool(&sanity.boolean)?; // writer.write_string("opt_uint32")?; - // writer.write_nullable_u32(&sanity.opt_uint32)?; + // writer.write_optional_u32(&sanity.opt_uint32)?; // writer.write_string("opt_bool")?; - // writer.write_nullable_bool(&sanity.opt_bool)?; + // writer.write_optional_bool(&sanity.opt_bool)?; // writer.write_string("float32")?; // writer.write_f32(sanity.float32)?; // writer.write_string("float64")?; @@ -143,7 +143,7 @@ fn deserialize_sanity(reader: &mut R, sanity: &mut Sanity) -> Result { - sanity.nil = reader.read_nullable_string()?; + sanity.nil = reader.read_optional_string()?; } "int8" => { sanity.int8 = reader.read_i8()?; @@ -167,10 +167,10 @@ fn deserialize_sanity(reader: &mut R, sanity: &mut Sanity) -> Result { - // sanity.opt_uint32 = reader.read_nullable_u32()?; + // sanity.opt_uint32 = reader.read_optional_u32()?; // }, // "opt_bool" => { - // sanity.opt_bool = reader.read_nullable_bool()?; + // sanity.opt_bool = reader.read_optional_bool()?; // }, // "float32" => { // sanity.float32 = reader.read_f32()?; @@ -228,7 +228,7 @@ fn deserialize_with_overflow( match field.as_str() { "nil" => { - sanity.nil = reader.read_nullable_string()?; + sanity.nil = reader.read_optional_string()?; } "int8" => { sanity.int8 = reader.read_i16()? as i8; @@ -252,10 +252,10 @@ fn deserialize_with_overflow( sanity.boolean = reader.read_bool()?; } // "opt_uint32" => { - // sanity.opt_uint32 = reader.read_nullable_u32()?; + // sanity.opt_uint32 = reader.read_optional_u32()?; // }, // "opt_bool" => { - // sanity.opt_bool = reader.read_nullable_bool()?; + // sanity.opt_bool = reader.read_optional_bool()?; // }, // "float32" => { // sanity.float32 = reader.read_f64()? as f32; @@ -299,7 +299,7 @@ fn deserialize_with_invalid_types( match field.as_str() { "nil" => { - sanity.nil = reader.read_nullable_string()?; + sanity.nil = reader.read_optional_string()?; } "int8" => { sanity.int8 = reader.read_i8()?; @@ -323,10 +323,10 @@ fn deserialize_with_invalid_types( sanity.boolean = reader.read_bool()?; } // "opt_uint32" => { - // sanity.opt_uint32 = reader.read_nullable_u32()?; + // sanity.opt_uint32 = reader.read_optional_u32()?; // }, // "opt_bool" => { - // sanity.opt_bool = reader.read_nullable_bool()?; + // sanity.opt_bool = reader.read_optional_bool()?; // }, // "float32" => { // sanity.float32 = reader.read_f32()?;