MaxSize
A Rust library that provides a MaxSize trait, which gives the maximum size the borsh serialization of a struct or enum could be in bytes. Implementations for simple types and a derive macro are included to make it easy to use with your custom types.
Features
MaxSizetrait: Get the maximum borsh serialized size of a type in bytes.- Implementations for simple types: Integers, floats, etc.
- Derive macro: Automatically implement
MaxSizefor your structs and enums.
Usage
- Add the dependency to your
Cargo.toml:
[]
= "0.1"
borsh-max-size contains optional arrayvec and solana-program features that add support for those libraries.
- Use the
MaxSizetrait in your code:
use MaxSize;
let max_size = i32max_size; // for simple types
assert_eq!;
- Derive
MaxSizefor your own types
use MaxSize;
println!;
License
This project is licensed under the MIT License. See the LICENSE.md file for details.