pub fn new(data: &[u8]) -> Result<Prefix> {
        let (raw_version, remain) = varint_decode::u64(data).map_err(other)?;
        let version = Version::try_from(raw_version).map_err(other)?;
        let (codec, remain) = varint_decode::u64(remain).map_err(other)?;
        let (mh_type, remain) = varint_decode::u64(remain).map_err(other)?;
        let (mh_len, _remain) = varint_decode::usize(remain).map_err(other)?;
        Ok(Prefix {
            version,
            codec,
            mh_type,
            mh_len,
        })
    }
/// Create a new prefix from encoded bytes.
Create a new prefix from encoded bytes.
Create a new prefix from encoded bytes .
pub fn new(data: &[u8]) -> Result<Prefix> {
        let (raw_version, remain) = varint_decode::u64(data).map_err(other)?;
        let version = Version::try_from(raw_version).map_err(other)?;
        let (codec, remain) = varint_decode::u64(remain).map_err(other)?;
        let (mh_type, remain) = varint_decode::u64(remain).map_err(other)?;
        let (mh_len, _remain) = varint_decode::usize(remain).map_err(other)?;
        Ok(Prefix {
            version,
            codec,
            mh_type,
            mh_len,
        })
    }
pub fn new ( data : & [ u8 ] ) -> Result < Prefix > { let ( raw_version , remain ) = varint_decode :: u64 ( data ) . map_err ( other ) ? ; let version = Version :: try_from ( raw_version ) . map_err ( other ) ? ; let ( codec , remain ) = varint_decode :: u64 ( remain ) . map_err ( other ) ? ; let ( mh_type , remain ) = varint_decode :: u64 ( remain ) . map_err ( other ) ? ; let ( mh_len , _remain ) = varint_decode :: usize ( remain ) . map_err ( other ) ? ; Ok ( Prefix { version , codec , mh_type , mh_len , } ) }
Create a new prefix from encoded bytes.
Create a new prefix from encoded bytes .
data
&[u8]
data
&[u8]