Open MrFoxPro opened 2 months ago
Thanks @MrFoxPro for your work. It looks like the lint error is on main
but the test compilation error is yours.
Thanks @MrFoxPro for your work. It looks like the lint error is on
main
but the test compilation error is yours.
Yep, PR requires some polishing
I thought one way to speedup encoding is to preallocate chunk for fixed-size values of type by recursive lookup of it in code generator and adding flag to "noAlloc" in writeX
functions
I decided to change TypeScript implementation. Now it looks like this:
enum MultiEnum {
VariantA(i32),
VariantB(String),
VariantC { x: u8, y: f64 },
UnitVariant,
}
struct ComplexStruct {
inner: SimpleStruct,
flag: bool,
items: Vec<MultiEnum>,
unit: UnitStruct,
newtype: NewtypeStruct,
tuple: TupleStruct,
tupple_inline: (String, i32),
map: HashMap<i32, i64>
}
->
export const ComplexStruct_obj: Registry.ComplexStruct = {
inner: { a: 42, b: "Hello" },
flag: true,
items: [
{ $: "variant_a", $0: 10 },
{ $: "variant_b", $0: "World" }
],
unit: null,
newtype: 99,
tuple: { $0: 123, $1: 45.67, $2: "Test" },
tupple_inline: { $0: "SomeString", $1: 777 },
map: new Map().set(3, 7n)
}
Closes https://github.com/zefchain/serde-reflection/issues/43 Probably needs more tests Checkout
suite/typescript/ts/test.ts
andsuite/typescript/readme.md
for example usage and additional information You can fix and adjust as you want if you have timeBenchamrks:
Encode
Decode
Need investigation how to improve encoding. It's worth to look into protobuf-js implementation