near / borsh

Binary Object Representation Serializer for Hashing
https://borsh.io/
491 stars 41 forks source link

Serializing fixed sized arrays #36

Closed mikhailOK closed 3 years ago

mikhailOK commented 4 years ago

After #33 borsh can serialize fixed sized arrays of any type, but deserialize only byte arrays. That's inconsistent

MaksymZavershynskyi commented 4 years ago

Since there is no trait specialization available in stable Rust we should only implement serializer/deserializer for standard types. So the solution to this issue is to remove serialization of non-primitive arrays and add serializers for primitive arrays.

We should also further investigate how bincode and serder address this issue. Assigning to @fckt

jsoneaday commented 3 years ago

Do you guys have a sample of deserializing an array of some type?

nonergodic commented 3 years ago

Any update on this?

nonergodic commented 3 years ago

Hah, just read the code and found that it was actually implemented with 0.9.1 release... i.e. 6 days ago!

just had to update my cargo.toml dependency to: borsh = { version = "0.9.1", features = ["const-generics"] } and now things work ❤️

bowenwang1996 commented 3 years ago

So looks like this can be closed