Skip to main content

LengthPrefix

Trait LengthPrefix 

pub trait LengthPrefix:
    Copy
    + Encode
    + Decode {
    // Required methods
    fn from_len(len: usize) -> Option<Self>;
    fn to_len(self) -> usize;
}
Expand description

Integer type of a length prefix.

Required Methods§

fn from_len(len: usize) -> Option<Self>

Converts a length, or returns None if it doesn’t fit.

fn to_len(self) -> usize

Converts the prefix into a length.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

§

impl LengthPrefix for u8

§

fn from_len(len: usize) -> Option<Self>

§

fn to_len(self) -> usize

§

impl LengthPrefix for u16

§

fn from_len(len: usize) -> Option<Self>

§

fn to_len(self) -> usize

§

impl LengthPrefix for u32

§

fn from_len(len: usize) -> Option<Self>

§

fn to_len(self) -> usize

Implementors§