pub fn serialize<T: ?Sized, S, C>(value: &T, size_limit: S) -> Result<Vec<u8>>
where
    T: serde::Serialize,
    S: SizeLimit,
    C: Encapsulation,
{
    let mut writer = match size_limit.limit() {
        Some(limit) => {
            let actual_size = calc_serialized_size_bounded(value, limit)?;
            Vec::with_capacity(actual_size as usize)
        }
        None => {
            let size = calc_serialized_size(value) as usize;
            Vec::with_capacity(size)
        }
    };

    serialize_into::<_, _, _, C>(&mut writer, value, Infinite)?;
    Ok(writer)
}
/// Serializes a serializable object into a `Vec` of bytes with the encapsulation.
Serializes a serializable object into a `Vec` of bytes with the encapsulation.
Serializes a serializable object into a ` Vec ` of bytes with the encapsulation .
pub fn serialize<T: ?Sized, S, C>(value: &T, size_limit: S) -> Result<Vec<u8>>
where
    T: serde::Serialize,
    S: SizeLimit,
    C: Encapsulation,
{
    let mut writer = match size_limit.limit() {
        Some(limit) => {
            let actual_size = calc_serialized_size_bounded(value, limit)?;
            Vec::with_capacity(actual_size as usize)
        }
        None => {
            let size = calc_serialized_size(value) as usize;
            Vec::with_capacity(size)
        }
    };
    serialize_into::<_, _, _, C>(&mut writer, value, Infinite)?;
    Ok(writer)
}
pub fn serialize < T : ? Sized , S , C > ( value : & T , size_limit : S ) -> Result < Vec < u8 > > where T : serde :: Serialize , S : SizeLimit , C : Encapsulation , { let mut writer = match size_limit . limit ( ) { Some ( limit ) => { let actual_size = calc_serialized_size_bounded ( value , limit ) ? ; Vec :: with_capacity ( actual_size as usize ) } None => { let size = calc_serialized_size ( value ) as usize ; Vec :: with_capacity ( size ) } } ; serialize_into :: < _ , _ , _ , C > ( & mut writer , value , Infinite ) ? ; Ok ( writer ) }
Serializes a serializable object into a `Vec` of bytes with the encapsulation.
Serializes a serializable object into a ` Vec ` of bytes with the encapsulation .
value
&T
size_limit
S
value
&T
size_limit
S