near / borsh-rs

Rust implementation of Binary Object Representation Serializer for Hashing
https://borsh.io/
Apache License 2.0
299 stars 65 forks source link

feat: Introduce `max_serialized_size` function #209

Closed mina86 closed 12 months ago

mina86 commented 1 year ago

The new borsh::max_serialized_size helper function returns the length of the longest possible encoding of given type. This may be used to preallocate output buffers or calculate minimum size of a memory regions needed to keep the values (e.g. in case of Solana accounts).