Skip to content

Latest commit

 

History

History
27 lines (19 loc) · 552 Bytes

README.md

File metadata and controls

27 lines (19 loc) · 552 Bytes

borsh-size-rs

Calculate size of struct serialized with borsh

Example

#[derive(BorshSerialize, BorshDeserialize, BorshSize)]
pub struct VotingAccount {
    pub uid: String,
    pub voting_name: String,
    pub voting_options: Vec<VotingOption>,
}

voting_account = VotingAccount {
    uid: voting_uid,
    voting_name: voting_name,
    voting_options: Vec::new(),
};

// get size of borsh serilized data
let size = voting_account.calculate_borsh_size();

// now use size for something usefull like creating account on solace chain