MultiEncoded

Struct MultiEncoded 

Source
pub struct MultiEncoded(/* private fields */);
Expand description

Multi-encoded byte slice.

Implementations§

Source§

impl MultiEncoded

Source

pub fn new(bytes: &[u8]) -> Result<&Self, Error>

Creates a new multi-encoded slice from the given bytes.

Following the [unsigned-varint] specification and to avoid memory attacks, the coded must be encoded on at most 9 bytes (63 bits unsigned varint).

unsigned-varint

Source

pub unsafe fn new_unchecked(bytes: &[u8]) -> &Self

Creates a new multi-encoded slice from the given bytes without checking the codec.

§Safety

Following the [unsigned-varint] specification and to avoid memory attacks, the coded must be encoded on at most 9 bytes (63 bits unsigned varint).

unsigned-varint

Source

pub fn len(&self) -> usize

Source

pub fn parts(&self) -> (u64, &[u8])

Source

pub fn codec(&self) -> u64

Source

pub fn data(&self) -> &[u8]

Source

pub fn as_bytes(&self) -> &[u8]

Returns the raw bytes, including the codec prefix.

Source

pub fn decode<T: MultiCodec>(&self) -> Result<T, Error>

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more