tinyvec icon indicating copy to clipboard operation
tinyvec copied to clipboard

Add implementation of Borsh::(De)Serialize traits

Open totikom opened this issue 3 years ago • 3 comments

The same way, as you have serde traits under serde feature, you can add borsh traits under borsh feature.

totikom avatar Sep 30 '21 21:09 totikom

I would accept such a PR but am unfamiliar with the crate and am unlikely to do this myself.

Lokathor avatar Sep 30 '21 21:09 Lokathor

Looks like Borsh is implemented for both [T; N] and &[T], so it is possible, that #[derive(BorshSerialize)] will be sufficient. I'll try it and, if it will be successful, send a PR.

totikom avatar Sep 30 '21 21:09 totikom

The implementation of BorshSerialize specifically should probably just coerce TinyVec to a slice and serialize that. Deserialization, on the other hand, is trickier.

Note that it's also possible to implement this in borsh crate rather than tinyvec, and it may make more sense to do so.

Shnatsel avatar Sep 30 '21 21:09 Shnatsel