pub fn calc_serialized_size_bounded<T: ?Sized>(value: &T, max: u64) -> Result<u64>
where
    T: serde::Serialize,
{
    use crate::encapsulation::ENCAPSULATION_HEADER_SIZE;

    if max < ENCAPSULATION_HEADER_SIZE {
        Err(Error::SizeLimit)
    } else {
        size::calc_serialized_data_size_bounded(value, max)
            .map(|size| size + ENCAPSULATION_HEADER_SIZE)
    }
}
/// Given a maximum size limit, check how large an object would be if it were
/// to be serialized with a encapsulation.
Given a maximum size limit, check how large an object would be if it were
to be serialized with a encapsulation.
Given a maximum size limit check how large an object would be if it were to be serialized with a encapsulation .
pub fn calc_serialized_size_bounded<T: ?Sized>(value: &T, max: u64) -> Result<u64>
where
    T: serde::Serialize,
{
    use crate::encapsulation::ENCAPSULATION_HEADER_SIZE;
    if max < ENCAPSULATION_HEADER_SIZE {
        Err(Error::SizeLimit)
    } else {
        size::calc_serialized_data_size_bounded(value, max)
            .map(|size| size + ENCAPSULATION_HEADER_SIZE)
    }
}
pub fn calc_serialized_size_bounded < T : ? Sized > ( value : & T , max : u64 ) -> Result < u64 > where T : serde :: Serialize , { use crate :: encapsulation :: ENCAPSULATION_HEADER_SIZE ; if max < ENCAPSULATION_HEADER_SIZE { Err ( Error :: SizeLimit ) } else { size :: calc_serialized_data_size_bounded ( value , max ) . map ( | size | size + ENCAPSULATION_HEADER_SIZE ) } }
Given a maximum size limit, check how large an object would be if it were
to be serialized with a encapsulation.
Given a maximum size limit check how large an object would be if it were to be serialized with a encapsulation .
value
&T
max
u64
value
&T
max
u64