@arrirpc/codegen-rust 0.77.1 → 0.79.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +33 -33
- package/dist/index.mjs +33 -33
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
@@ -96,7 +96,7 @@ function validRustName(name) {
|
|
96
96
|
}
|
97
97
|
path__default.resolve(__dirname, "../.temp");
|
98
98
|
function outputIsOptionType(schema, context) {
|
99
|
-
return schema.
|
99
|
+
return schema.isNullable === true || context.isOptional === true;
|
100
100
|
}
|
101
101
|
function getTypeName(schema, context) {
|
102
102
|
if (schema.metadata?.id) {
|
@@ -171,7 +171,7 @@ function rustArrayFromSchema(schema, context) {
|
|
171
171
|
typeId: typeName,
|
172
172
|
finalTypeName: typeName,
|
173
173
|
defaultValue,
|
174
|
-
isNullable: schema.
|
174
|
+
isNullable: schema.isNullable ?? false,
|
175
175
|
fromJsonTemplate(input, key) {
|
176
176
|
const innerKey = validRustIdentifier(`${key}_val`);
|
177
177
|
if (isOptionType) {
|
@@ -502,7 +502,7 @@ function rustEnumFromSchema(schema, context) {
|
|
502
502
|
typeId: enumName,
|
503
503
|
finalTypeName: typeName,
|
504
504
|
defaultValue,
|
505
|
-
isNullable: schema.
|
505
|
+
isNullable: schema.isNullable ?? false,
|
506
506
|
fromJsonTemplate(input, key) {
|
507
507
|
const innerKey = validRustIdentifier(`${key}_val`);
|
508
508
|
if (isOptionType) {
|
@@ -533,7 +533,7 @@ function rustEnumFromSchema(schema, context) {
|
|
533
533
|
_ => {}
|
534
534
|
}`;
|
535
535
|
}
|
536
|
-
if (schema.
|
536
|
+
if (schema.isNullable) {
|
537
537
|
return `match ${input} {
|
538
538
|
Some(${innerKey}) => {
|
539
539
|
${target}.push(format!("${key}={}", ${innerKey}.serial_value()));
|
@@ -610,7 +610,7 @@ function rustObjectFromSchema(schema, context) {
|
|
610
610
|
typeId: structName,
|
611
611
|
finalTypeName: typeName,
|
612
612
|
defaultValue,
|
613
|
-
isNullable: schema.
|
613
|
+
isNullable: schema.isNullable ?? false,
|
614
614
|
fromJsonTemplate(input, key) {
|
615
615
|
const innerKey = validRustIdentifier(`${key}_val`);
|
616
616
|
if (isOptionType) {
|
@@ -835,7 +835,7 @@ function rustStringFromSchema(schema, context) {
|
|
835
835
|
typeId: typeName,
|
836
836
|
finalTypeName: typeName,
|
837
837
|
defaultValue,
|
838
|
-
isNullable: schema.
|
838
|
+
isNullable: schema.isNullable ?? false,
|
839
839
|
fromJsonTemplate(input, key) {
|
840
840
|
const innerKey = validRustIdentifier(`${key}_val`);
|
841
841
|
if (isOptionType) {
|
@@ -862,7 +862,7 @@ function rustStringFromSchema(schema, context) {
|
|
862
862
|
_ => {}
|
863
863
|
}`;
|
864
864
|
}
|
865
|
-
if (schema.
|
865
|
+
if (schema.isNullable) {
|
866
866
|
return `match ${input} {
|
867
867
|
Some(${innerKey}) => {
|
868
868
|
${target}.push(format!("${key}={}", ${innerKey}));
|
@@ -885,7 +885,7 @@ function rustBooleanFromSchema(schema, context) {
|
|
885
885
|
typeId: typeName,
|
886
886
|
finalTypeName: typeName,
|
887
887
|
defaultValue,
|
888
|
-
isNullable: schema.
|
888
|
+
isNullable: schema.isNullable ?? false,
|
889
889
|
fromJsonTemplate(input, key) {
|
890
890
|
const innerKey = validRustIdentifier(`${key}_val`);
|
891
891
|
if (isOptionType) {
|
@@ -912,7 +912,7 @@ function rustBooleanFromSchema(schema, context) {
|
|
912
912
|
_ => {}
|
913
913
|
}`;
|
914
914
|
}
|
915
|
-
if (schema.
|
915
|
+
if (schema.isNullable) {
|
916
916
|
return `match ${input} {
|
917
917
|
Some(${innerKey}) => {
|
918
918
|
${target}.push(format!("${key}={}", ${innerKey}));
|
@@ -935,7 +935,7 @@ function rustTimestampFromSchema(schema, context) {
|
|
935
935
|
typeId: typeName,
|
936
936
|
finalTypeName: typeName,
|
937
937
|
defaultValue,
|
938
|
-
isNullable: schema.
|
938
|
+
isNullable: schema.isNullable ?? false,
|
939
939
|
fromJsonTemplate(input, key) {
|
940
940
|
const innerKey = validRustIdentifier(`${key}_val`);
|
941
941
|
if (isOptionType) {
|
@@ -973,7 +973,7 @@ function rustTimestampFromSchema(schema, context) {
|
|
973
973
|
_ => {}
|
974
974
|
}`;
|
975
975
|
}
|
976
|
-
if (schema.
|
976
|
+
if (schema.isNullable) {
|
977
977
|
return `match ${input} {
|
978
978
|
Some(${innerKey}) => {
|
979
979
|
${target}.push(format!(
|
@@ -1002,7 +1002,7 @@ function rustF32FromSchema(schema, context) {
|
|
1002
1002
|
typeId: typeName,
|
1003
1003
|
finalTypeName: typeName,
|
1004
1004
|
defaultValue,
|
1005
|
-
isNullable: schema.
|
1005
|
+
isNullable: schema.isNullable ?? false,
|
1006
1006
|
fromJsonTemplate(input, key) {
|
1007
1007
|
const innerKey = validRustIdentifier(`${key}_val`);
|
1008
1008
|
if (isOptionType) {
|
@@ -1034,7 +1034,7 @@ function rustF32FromSchema(schema, context) {
|
|
1034
1034
|
_ => {}
|
1035
1035
|
}`;
|
1036
1036
|
}
|
1037
|
-
if (schema.
|
1037
|
+
if (schema.isNullable) {
|
1038
1038
|
return `match ${input} {
|
1039
1039
|
Some(${innerKey}) => {
|
1040
1040
|
${target}.push(format!("${key}={}", ${innerKey}));
|
@@ -1057,7 +1057,7 @@ function rustF64FromSchema(schema, context) {
|
|
1057
1057
|
typeId: typeName,
|
1058
1058
|
finalTypeName: typeName,
|
1059
1059
|
defaultValue,
|
1060
|
-
isNullable: schema.
|
1060
|
+
isNullable: schema.isNullable ?? false,
|
1061
1061
|
fromJsonTemplate(input, key) {
|
1062
1062
|
const innerKey = validRustIdentifier(`${key}_val`);
|
1063
1063
|
if (isOptionType) {
|
@@ -1089,7 +1089,7 @@ function rustF64FromSchema(schema, context) {
|
|
1089
1089
|
_ => {}
|
1090
1090
|
}`;
|
1091
1091
|
}
|
1092
|
-
if (schema.
|
1092
|
+
if (schema.isNullable) {
|
1093
1093
|
return `match ${input} {
|
1094
1094
|
Some(${innerKey}) => {
|
1095
1095
|
${target}.push(format!("${key}={}", ${innerKey}));
|
@@ -1112,7 +1112,7 @@ function rustI8FromSchema(schema, context) {
|
|
1112
1112
|
typeId: typeName,
|
1113
1113
|
finalTypeName: typeName,
|
1114
1114
|
defaultValue,
|
1115
|
-
isNullable: schema.
|
1115
|
+
isNullable: schema.isNullable ?? false,
|
1116
1116
|
fromJsonTemplate(input, key) {
|
1117
1117
|
const innerKey = validRustIdentifier(`${key}_val`);
|
1118
1118
|
if (isOptionType) {
|
@@ -1147,7 +1147,7 @@ function rustI8FromSchema(schema, context) {
|
|
1147
1147
|
_ => {}
|
1148
1148
|
}`;
|
1149
1149
|
}
|
1150
|
-
if (schema.
|
1150
|
+
if (schema.isNullable) {
|
1151
1151
|
return `match ${input} {
|
1152
1152
|
Some(${innerKey}) => {
|
1153
1153
|
${target}.push(format!("${key}={}", ${innerKey}));
|
@@ -1170,7 +1170,7 @@ function rustU8FromSchema(schema, context) {
|
|
1170
1170
|
typeId: typeName,
|
1171
1171
|
finalTypeName: typeName,
|
1172
1172
|
defaultValue,
|
1173
|
-
isNullable: schema.
|
1173
|
+
isNullable: schema.isNullable ?? false,
|
1174
1174
|
fromJsonTemplate(input, key) {
|
1175
1175
|
const innerKey = validRustIdentifier(`${key}_val`);
|
1176
1176
|
if (isOptionType) {
|
@@ -1205,7 +1205,7 @@ function rustU8FromSchema(schema, context) {
|
|
1205
1205
|
_ => {}
|
1206
1206
|
}`;
|
1207
1207
|
}
|
1208
|
-
if (schema.
|
1208
|
+
if (schema.isNullable) {
|
1209
1209
|
return `match ${input} {
|
1210
1210
|
Some(${innerKey}) => {
|
1211
1211
|
${target}.push(format!("${key}={}", ${innerKey}));
|
@@ -1228,7 +1228,7 @@ function rustI16FromSchema(schema, context) {
|
|
1228
1228
|
typeId: typeName,
|
1229
1229
|
finalTypeName: typeName,
|
1230
1230
|
defaultValue,
|
1231
|
-
isNullable: schema.
|
1231
|
+
isNullable: schema.isNullable ?? false,
|
1232
1232
|
fromJsonTemplate(input, key) {
|
1233
1233
|
const innerKey = validRustIdentifier(`${key}_val`);
|
1234
1234
|
if (isOptionType) {
|
@@ -1263,7 +1263,7 @@ function rustI16FromSchema(schema, context) {
|
|
1263
1263
|
_ => {}
|
1264
1264
|
}`;
|
1265
1265
|
}
|
1266
|
-
if (schema.
|
1266
|
+
if (schema.isNullable) {
|
1267
1267
|
return `match ${input} {
|
1268
1268
|
Some(${innerKey}) => {
|
1269
1269
|
${target}.push(format!("${key}={}", ${innerKey}));
|
@@ -1286,7 +1286,7 @@ function rustU16FromSchema(schema, context) {
|
|
1286
1286
|
typeId: typeName,
|
1287
1287
|
finalTypeName: typeName,
|
1288
1288
|
defaultValue,
|
1289
|
-
isNullable: schema.
|
1289
|
+
isNullable: schema.isNullable ?? false,
|
1290
1290
|
fromJsonTemplate(input, key) {
|
1291
1291
|
const innerKey = validRustIdentifier(`${key}_val`);
|
1292
1292
|
if (isOptionType) {
|
@@ -1321,7 +1321,7 @@ function rustU16FromSchema(schema, context) {
|
|
1321
1321
|
_ => {}
|
1322
1322
|
}`;
|
1323
1323
|
}
|
1324
|
-
if (schema.
|
1324
|
+
if (schema.isNullable) {
|
1325
1325
|
return `match ${input} {
|
1326
1326
|
Some(${innerKey}) => {
|
1327
1327
|
${target}.push(format!("${key}={}", ${innerKey}));
|
@@ -1344,7 +1344,7 @@ function rustI32FromSchema(schema, context) {
|
|
1344
1344
|
typeId: typeName,
|
1345
1345
|
finalTypeName: typeName,
|
1346
1346
|
defaultValue,
|
1347
|
-
isNullable: schema.
|
1347
|
+
isNullable: schema.isNullable ?? false,
|
1348
1348
|
fromJsonTemplate(input, key) {
|
1349
1349
|
const innerKey = validRustIdentifier(`${key}_val`);
|
1350
1350
|
if (isOptionType) {
|
@@ -1379,7 +1379,7 @@ function rustI32FromSchema(schema, context) {
|
|
1379
1379
|
_ => {}
|
1380
1380
|
}`;
|
1381
1381
|
}
|
1382
|
-
if (schema.
|
1382
|
+
if (schema.isNullable) {
|
1383
1383
|
return `match ${input} {
|
1384
1384
|
Some(${innerKey}) => {
|
1385
1385
|
${target}.push(format!("${key}={}", ${innerKey}));
|
@@ -1402,7 +1402,7 @@ function rustU32FromSchema(schema, context) {
|
|
1402
1402
|
typeId: typeName,
|
1403
1403
|
finalTypeName: typeName,
|
1404
1404
|
defaultValue,
|
1405
|
-
isNullable: schema.
|
1405
|
+
isNullable: schema.isNullable ?? false,
|
1406
1406
|
fromJsonTemplate(input, key) {
|
1407
1407
|
const innerKey = validRustIdentifier(`${key}_val`);
|
1408
1408
|
if (isOptionType) {
|
@@ -1437,7 +1437,7 @@ function rustU32FromSchema(schema, context) {
|
|
1437
1437
|
_ => {}
|
1438
1438
|
}`;
|
1439
1439
|
}
|
1440
|
-
if (schema.
|
1440
|
+
if (schema.isNullable) {
|
1441
1441
|
return `match ${input} {
|
1442
1442
|
Some(${innerKey}) => {
|
1443
1443
|
${target}.push(format!("${key}={}", ${innerKey}));
|
@@ -1460,7 +1460,7 @@ function rustI64FromSchema(schema, context) {
|
|
1460
1460
|
typeId: typeName,
|
1461
1461
|
finalTypeName: typeName,
|
1462
1462
|
defaultValue,
|
1463
|
-
isNullable: schema.
|
1463
|
+
isNullable: schema.isNullable ?? false,
|
1464
1464
|
fromJsonTemplate(input, key) {
|
1465
1465
|
const innerKey = validRustIdentifier(`${key}_val`);
|
1466
1466
|
if (isOptionType) {
|
@@ -1492,7 +1492,7 @@ function rustI64FromSchema(schema, context) {
|
|
1492
1492
|
_ => {}
|
1493
1493
|
}`;
|
1494
1494
|
}
|
1495
|
-
if (schema.
|
1495
|
+
if (schema.isNullable) {
|
1496
1496
|
return `match ${input} {
|
1497
1497
|
Some(${innerKey}) => {
|
1498
1498
|
${target}.push(format!("${key}={}", ${innerKey}));
|
@@ -1515,7 +1515,7 @@ function rustU64FromSchema(schema, context) {
|
|
1515
1515
|
typeId: typeName,
|
1516
1516
|
finalTypeName: typeName,
|
1517
1517
|
defaultValue,
|
1518
|
-
isNullable: schema.
|
1518
|
+
isNullable: schema.isNullable ?? false,
|
1519
1519
|
fromJsonTemplate(input, key) {
|
1520
1520
|
const innerKey = validRustIdentifier(`${key}_val`);
|
1521
1521
|
if (isOptionType) {
|
@@ -1547,7 +1547,7 @@ function rustU64FromSchema(schema, context) {
|
|
1547
1547
|
_ => {}
|
1548
1548
|
}`;
|
1549
1549
|
}
|
1550
|
-
if (schema.
|
1550
|
+
if (schema.isNullable) {
|
1551
1551
|
return `match ${input} {
|
1552
1552
|
Some(${innerKey}) => {
|
1553
1553
|
${target}.push(format!("${key}={}", ${innerKey}));
|
@@ -1741,7 +1741,7 @@ function rustRecordFromSchema(schema, context) {
|
|
1741
1741
|
typeId: typeName,
|
1742
1742
|
finalTypeName: typeName,
|
1743
1743
|
defaultValue,
|
1744
|
-
isNullable: schema.
|
1744
|
+
isNullable: schema.isNullable ?? false,
|
1745
1745
|
fromJsonTemplate(input, key) {
|
1746
1746
|
const innerKey = validRustIdentifier(`${key}_val`);
|
1747
1747
|
if (isOptionType) {
|
@@ -1827,7 +1827,7 @@ function rustRefFromSchema(schema, context) {
|
|
1827
1827
|
typeId: typeName,
|
1828
1828
|
finalTypeName: typeName,
|
1829
1829
|
defaultValue,
|
1830
|
-
isNullable: schema.
|
1830
|
+
isNullable: schema.isNullable ?? false,
|
1831
1831
|
fromJsonTemplate(input, key) {
|
1832
1832
|
const innerKey = validRustIdentifier(`${key}_val`);
|
1833
1833
|
const valFromJson = (input2) => {
|
package/dist/index.mjs
CHANGED
@@ -88,7 +88,7 @@ function validRustName(name) {
|
|
88
88
|
}
|
89
89
|
path.resolve(__dirname, "../.temp");
|
90
90
|
function outputIsOptionType(schema, context) {
|
91
|
-
return schema.
|
91
|
+
return schema.isNullable === true || context.isOptional === true;
|
92
92
|
}
|
93
93
|
function getTypeName(schema, context) {
|
94
94
|
if (schema.metadata?.id) {
|
@@ -163,7 +163,7 @@ function rustArrayFromSchema(schema, context) {
|
|
163
163
|
typeId: typeName,
|
164
164
|
finalTypeName: typeName,
|
165
165
|
defaultValue,
|
166
|
-
isNullable: schema.
|
166
|
+
isNullable: schema.isNullable ?? false,
|
167
167
|
fromJsonTemplate(input, key) {
|
168
168
|
const innerKey = validRustIdentifier(`${key}_val`);
|
169
169
|
if (isOptionType) {
|
@@ -494,7 +494,7 @@ function rustEnumFromSchema(schema, context) {
|
|
494
494
|
typeId: enumName,
|
495
495
|
finalTypeName: typeName,
|
496
496
|
defaultValue,
|
497
|
-
isNullable: schema.
|
497
|
+
isNullable: schema.isNullable ?? false,
|
498
498
|
fromJsonTemplate(input, key) {
|
499
499
|
const innerKey = validRustIdentifier(`${key}_val`);
|
500
500
|
if (isOptionType) {
|
@@ -525,7 +525,7 @@ function rustEnumFromSchema(schema, context) {
|
|
525
525
|
_ => {}
|
526
526
|
}`;
|
527
527
|
}
|
528
|
-
if (schema.
|
528
|
+
if (schema.isNullable) {
|
529
529
|
return `match ${input} {
|
530
530
|
Some(${innerKey}) => {
|
531
531
|
${target}.push(format!("${key}={}", ${innerKey}.serial_value()));
|
@@ -602,7 +602,7 @@ function rustObjectFromSchema(schema, context) {
|
|
602
602
|
typeId: structName,
|
603
603
|
finalTypeName: typeName,
|
604
604
|
defaultValue,
|
605
|
-
isNullable: schema.
|
605
|
+
isNullable: schema.isNullable ?? false,
|
606
606
|
fromJsonTemplate(input, key) {
|
607
607
|
const innerKey = validRustIdentifier(`${key}_val`);
|
608
608
|
if (isOptionType) {
|
@@ -827,7 +827,7 @@ function rustStringFromSchema(schema, context) {
|
|
827
827
|
typeId: typeName,
|
828
828
|
finalTypeName: typeName,
|
829
829
|
defaultValue,
|
830
|
-
isNullable: schema.
|
830
|
+
isNullable: schema.isNullable ?? false,
|
831
831
|
fromJsonTemplate(input, key) {
|
832
832
|
const innerKey = validRustIdentifier(`${key}_val`);
|
833
833
|
if (isOptionType) {
|
@@ -854,7 +854,7 @@ function rustStringFromSchema(schema, context) {
|
|
854
854
|
_ => {}
|
855
855
|
}`;
|
856
856
|
}
|
857
|
-
if (schema.
|
857
|
+
if (schema.isNullable) {
|
858
858
|
return `match ${input} {
|
859
859
|
Some(${innerKey}) => {
|
860
860
|
${target}.push(format!("${key}={}", ${innerKey}));
|
@@ -877,7 +877,7 @@ function rustBooleanFromSchema(schema, context) {
|
|
877
877
|
typeId: typeName,
|
878
878
|
finalTypeName: typeName,
|
879
879
|
defaultValue,
|
880
|
-
isNullable: schema.
|
880
|
+
isNullable: schema.isNullable ?? false,
|
881
881
|
fromJsonTemplate(input, key) {
|
882
882
|
const innerKey = validRustIdentifier(`${key}_val`);
|
883
883
|
if (isOptionType) {
|
@@ -904,7 +904,7 @@ function rustBooleanFromSchema(schema, context) {
|
|
904
904
|
_ => {}
|
905
905
|
}`;
|
906
906
|
}
|
907
|
-
if (schema.
|
907
|
+
if (schema.isNullable) {
|
908
908
|
return `match ${input} {
|
909
909
|
Some(${innerKey}) => {
|
910
910
|
${target}.push(format!("${key}={}", ${innerKey}));
|
@@ -927,7 +927,7 @@ function rustTimestampFromSchema(schema, context) {
|
|
927
927
|
typeId: typeName,
|
928
928
|
finalTypeName: typeName,
|
929
929
|
defaultValue,
|
930
|
-
isNullable: schema.
|
930
|
+
isNullable: schema.isNullable ?? false,
|
931
931
|
fromJsonTemplate(input, key) {
|
932
932
|
const innerKey = validRustIdentifier(`${key}_val`);
|
933
933
|
if (isOptionType) {
|
@@ -965,7 +965,7 @@ function rustTimestampFromSchema(schema, context) {
|
|
965
965
|
_ => {}
|
966
966
|
}`;
|
967
967
|
}
|
968
|
-
if (schema.
|
968
|
+
if (schema.isNullable) {
|
969
969
|
return `match ${input} {
|
970
970
|
Some(${innerKey}) => {
|
971
971
|
${target}.push(format!(
|
@@ -994,7 +994,7 @@ function rustF32FromSchema(schema, context) {
|
|
994
994
|
typeId: typeName,
|
995
995
|
finalTypeName: typeName,
|
996
996
|
defaultValue,
|
997
|
-
isNullable: schema.
|
997
|
+
isNullable: schema.isNullable ?? false,
|
998
998
|
fromJsonTemplate(input, key) {
|
999
999
|
const innerKey = validRustIdentifier(`${key}_val`);
|
1000
1000
|
if (isOptionType) {
|
@@ -1026,7 +1026,7 @@ function rustF32FromSchema(schema, context) {
|
|
1026
1026
|
_ => {}
|
1027
1027
|
}`;
|
1028
1028
|
}
|
1029
|
-
if (schema.
|
1029
|
+
if (schema.isNullable) {
|
1030
1030
|
return `match ${input} {
|
1031
1031
|
Some(${innerKey}) => {
|
1032
1032
|
${target}.push(format!("${key}={}", ${innerKey}));
|
@@ -1049,7 +1049,7 @@ function rustF64FromSchema(schema, context) {
|
|
1049
1049
|
typeId: typeName,
|
1050
1050
|
finalTypeName: typeName,
|
1051
1051
|
defaultValue,
|
1052
|
-
isNullable: schema.
|
1052
|
+
isNullable: schema.isNullable ?? false,
|
1053
1053
|
fromJsonTemplate(input, key) {
|
1054
1054
|
const innerKey = validRustIdentifier(`${key}_val`);
|
1055
1055
|
if (isOptionType) {
|
@@ -1081,7 +1081,7 @@ function rustF64FromSchema(schema, context) {
|
|
1081
1081
|
_ => {}
|
1082
1082
|
}`;
|
1083
1083
|
}
|
1084
|
-
if (schema.
|
1084
|
+
if (schema.isNullable) {
|
1085
1085
|
return `match ${input} {
|
1086
1086
|
Some(${innerKey}) => {
|
1087
1087
|
${target}.push(format!("${key}={}", ${innerKey}));
|
@@ -1104,7 +1104,7 @@ function rustI8FromSchema(schema, context) {
|
|
1104
1104
|
typeId: typeName,
|
1105
1105
|
finalTypeName: typeName,
|
1106
1106
|
defaultValue,
|
1107
|
-
isNullable: schema.
|
1107
|
+
isNullable: schema.isNullable ?? false,
|
1108
1108
|
fromJsonTemplate(input, key) {
|
1109
1109
|
const innerKey = validRustIdentifier(`${key}_val`);
|
1110
1110
|
if (isOptionType) {
|
@@ -1139,7 +1139,7 @@ function rustI8FromSchema(schema, context) {
|
|
1139
1139
|
_ => {}
|
1140
1140
|
}`;
|
1141
1141
|
}
|
1142
|
-
if (schema.
|
1142
|
+
if (schema.isNullable) {
|
1143
1143
|
return `match ${input} {
|
1144
1144
|
Some(${innerKey}) => {
|
1145
1145
|
${target}.push(format!("${key}={}", ${innerKey}));
|
@@ -1162,7 +1162,7 @@ function rustU8FromSchema(schema, context) {
|
|
1162
1162
|
typeId: typeName,
|
1163
1163
|
finalTypeName: typeName,
|
1164
1164
|
defaultValue,
|
1165
|
-
isNullable: schema.
|
1165
|
+
isNullable: schema.isNullable ?? false,
|
1166
1166
|
fromJsonTemplate(input, key) {
|
1167
1167
|
const innerKey = validRustIdentifier(`${key}_val`);
|
1168
1168
|
if (isOptionType) {
|
@@ -1197,7 +1197,7 @@ function rustU8FromSchema(schema, context) {
|
|
1197
1197
|
_ => {}
|
1198
1198
|
}`;
|
1199
1199
|
}
|
1200
|
-
if (schema.
|
1200
|
+
if (schema.isNullable) {
|
1201
1201
|
return `match ${input} {
|
1202
1202
|
Some(${innerKey}) => {
|
1203
1203
|
${target}.push(format!("${key}={}", ${innerKey}));
|
@@ -1220,7 +1220,7 @@ function rustI16FromSchema(schema, context) {
|
|
1220
1220
|
typeId: typeName,
|
1221
1221
|
finalTypeName: typeName,
|
1222
1222
|
defaultValue,
|
1223
|
-
isNullable: schema.
|
1223
|
+
isNullable: schema.isNullable ?? false,
|
1224
1224
|
fromJsonTemplate(input, key) {
|
1225
1225
|
const innerKey = validRustIdentifier(`${key}_val`);
|
1226
1226
|
if (isOptionType) {
|
@@ -1255,7 +1255,7 @@ function rustI16FromSchema(schema, context) {
|
|
1255
1255
|
_ => {}
|
1256
1256
|
}`;
|
1257
1257
|
}
|
1258
|
-
if (schema.
|
1258
|
+
if (schema.isNullable) {
|
1259
1259
|
return `match ${input} {
|
1260
1260
|
Some(${innerKey}) => {
|
1261
1261
|
${target}.push(format!("${key}={}", ${innerKey}));
|
@@ -1278,7 +1278,7 @@ function rustU16FromSchema(schema, context) {
|
|
1278
1278
|
typeId: typeName,
|
1279
1279
|
finalTypeName: typeName,
|
1280
1280
|
defaultValue,
|
1281
|
-
isNullable: schema.
|
1281
|
+
isNullable: schema.isNullable ?? false,
|
1282
1282
|
fromJsonTemplate(input, key) {
|
1283
1283
|
const innerKey = validRustIdentifier(`${key}_val`);
|
1284
1284
|
if (isOptionType) {
|
@@ -1313,7 +1313,7 @@ function rustU16FromSchema(schema, context) {
|
|
1313
1313
|
_ => {}
|
1314
1314
|
}`;
|
1315
1315
|
}
|
1316
|
-
if (schema.
|
1316
|
+
if (schema.isNullable) {
|
1317
1317
|
return `match ${input} {
|
1318
1318
|
Some(${innerKey}) => {
|
1319
1319
|
${target}.push(format!("${key}={}", ${innerKey}));
|
@@ -1336,7 +1336,7 @@ function rustI32FromSchema(schema, context) {
|
|
1336
1336
|
typeId: typeName,
|
1337
1337
|
finalTypeName: typeName,
|
1338
1338
|
defaultValue,
|
1339
|
-
isNullable: schema.
|
1339
|
+
isNullable: schema.isNullable ?? false,
|
1340
1340
|
fromJsonTemplate(input, key) {
|
1341
1341
|
const innerKey = validRustIdentifier(`${key}_val`);
|
1342
1342
|
if (isOptionType) {
|
@@ -1371,7 +1371,7 @@ function rustI32FromSchema(schema, context) {
|
|
1371
1371
|
_ => {}
|
1372
1372
|
}`;
|
1373
1373
|
}
|
1374
|
-
if (schema.
|
1374
|
+
if (schema.isNullable) {
|
1375
1375
|
return `match ${input} {
|
1376
1376
|
Some(${innerKey}) => {
|
1377
1377
|
${target}.push(format!("${key}={}", ${innerKey}));
|
@@ -1394,7 +1394,7 @@ function rustU32FromSchema(schema, context) {
|
|
1394
1394
|
typeId: typeName,
|
1395
1395
|
finalTypeName: typeName,
|
1396
1396
|
defaultValue,
|
1397
|
-
isNullable: schema.
|
1397
|
+
isNullable: schema.isNullable ?? false,
|
1398
1398
|
fromJsonTemplate(input, key) {
|
1399
1399
|
const innerKey = validRustIdentifier(`${key}_val`);
|
1400
1400
|
if (isOptionType) {
|
@@ -1429,7 +1429,7 @@ function rustU32FromSchema(schema, context) {
|
|
1429
1429
|
_ => {}
|
1430
1430
|
}`;
|
1431
1431
|
}
|
1432
|
-
if (schema.
|
1432
|
+
if (schema.isNullable) {
|
1433
1433
|
return `match ${input} {
|
1434
1434
|
Some(${innerKey}) => {
|
1435
1435
|
${target}.push(format!("${key}={}", ${innerKey}));
|
@@ -1452,7 +1452,7 @@ function rustI64FromSchema(schema, context) {
|
|
1452
1452
|
typeId: typeName,
|
1453
1453
|
finalTypeName: typeName,
|
1454
1454
|
defaultValue,
|
1455
|
-
isNullable: schema.
|
1455
|
+
isNullable: schema.isNullable ?? false,
|
1456
1456
|
fromJsonTemplate(input, key) {
|
1457
1457
|
const innerKey = validRustIdentifier(`${key}_val`);
|
1458
1458
|
if (isOptionType) {
|
@@ -1484,7 +1484,7 @@ function rustI64FromSchema(schema, context) {
|
|
1484
1484
|
_ => {}
|
1485
1485
|
}`;
|
1486
1486
|
}
|
1487
|
-
if (schema.
|
1487
|
+
if (schema.isNullable) {
|
1488
1488
|
return `match ${input} {
|
1489
1489
|
Some(${innerKey}) => {
|
1490
1490
|
${target}.push(format!("${key}={}", ${innerKey}));
|
@@ -1507,7 +1507,7 @@ function rustU64FromSchema(schema, context) {
|
|
1507
1507
|
typeId: typeName,
|
1508
1508
|
finalTypeName: typeName,
|
1509
1509
|
defaultValue,
|
1510
|
-
isNullable: schema.
|
1510
|
+
isNullable: schema.isNullable ?? false,
|
1511
1511
|
fromJsonTemplate(input, key) {
|
1512
1512
|
const innerKey = validRustIdentifier(`${key}_val`);
|
1513
1513
|
if (isOptionType) {
|
@@ -1539,7 +1539,7 @@ function rustU64FromSchema(schema, context) {
|
|
1539
1539
|
_ => {}
|
1540
1540
|
}`;
|
1541
1541
|
}
|
1542
|
-
if (schema.
|
1542
|
+
if (schema.isNullable) {
|
1543
1543
|
return `match ${input} {
|
1544
1544
|
Some(${innerKey}) => {
|
1545
1545
|
${target}.push(format!("${key}={}", ${innerKey}));
|
@@ -1733,7 +1733,7 @@ function rustRecordFromSchema(schema, context) {
|
|
1733
1733
|
typeId: typeName,
|
1734
1734
|
finalTypeName: typeName,
|
1735
1735
|
defaultValue,
|
1736
|
-
isNullable: schema.
|
1736
|
+
isNullable: schema.isNullable ?? false,
|
1737
1737
|
fromJsonTemplate(input, key) {
|
1738
1738
|
const innerKey = validRustIdentifier(`${key}_val`);
|
1739
1739
|
if (isOptionType) {
|
@@ -1819,7 +1819,7 @@ function rustRefFromSchema(schema, context) {
|
|
1819
1819
|
typeId: typeName,
|
1820
1820
|
finalTypeName: typeName,
|
1821
1821
|
defaultValue,
|
1822
|
-
isNullable: schema.
|
1822
|
+
isNullable: schema.isNullable ?? false,
|
1823
1823
|
fromJsonTemplate(input, key) {
|
1824
1824
|
const innerKey = validRustIdentifier(`${key}_val`);
|
1825
1825
|
const valFromJson = (input2) => {
|