devol-accounts-kit 0.3.4

SDK for interacting with the DeVol Network option trading platform on the Solana blockchain
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use std::cell::Ref;
use crate::dvl_error::DvlError;
use crate::errors::{AccountTag, ContractError};

pub trait DevolExpandableSizeAccount {
    fn expected_expanded_size(account_data: Ref<&mut [u8]>) -> usize;

    #[inline(always)]
    fn check_expanded_size(tag: AccountTag, account_data: Ref<&mut [u8]>) -> Result<(), DvlError> {
        let actual_size = account_data.len();
        if actual_size < Self::expected_expanded_size(account_data) {
            Err(DvlError::new_with_account(tag, ContractError::AccountSize))
        } else {
            Ok(())
        }
    }
}