pub fn deserialize_with_limit<T>(data: &[u8], size_limit: u64) -> Result<T, DeserializationError>
where
    T: DeserializeOwned,
{
    let mut cursor = Cursor::new(data);

    let value = bincode::DefaultOptions::new()
        .with_fixint_encoding()
        .allow_trailing_bytes()
        .with_limit(size_limit)
        .deserialize_from(&mut cursor)?;

    if cursor.position() != data.len() as u64 {
        return Err(DeserializationError::BytesLeftOver);
    }
    Ok(value)
}
/// Deserialize a `Deserialize` type with max size limit specified.
Deserialize a `Deserialize` type with max size limit specified.
Deserialize a ` Deserialize ` type with max size limit specified .
pub fn deserialize_with_limit<T>(data: &[u8], size_limit: u64) -> Result<T, DeserializationError>
where
    T: DeserializeOwned,
{
    let mut cursor = Cursor::new(data);
    let value = bincode::DefaultOptions::new()
        .with_fixint_encoding()
        .allow_trailing_bytes()
        .with_limit(size_limit)
        .deserialize_from(&mut cursor)?;
    if cursor.position() != data.len() as u64 {
        return Err(DeserializationError::BytesLeftOver);
    }
    Ok(value)
}
pub fn deserialize_with_limit < T > ( data : & [ u8 ] , size_limit : u64 ) -> Result < T , DeserializationError > where T : DeserializeOwned , { let mut cursor = Cursor :: new ( data ) ; let value = bincode :: DefaultOptions :: new ( ) . with_fixint_encoding ( ) . allow_trailing_bytes ( ) . with_limit ( size_limit ) . deserialize_from ( & mut cursor ) ? ; if cursor . position ( ) != data . len ( ) as u64 { return Err ( DeserializationError :: BytesLeftOver ) ; } Ok ( value ) }
Deserialize a `Deserialize` type with max size limit specified.
Deserialize a ` Deserialize ` type with max size limit specified .
data
&[u8]
size_limit
u64
data
&[u8]
size_limit
u64