Skip to main content

Decode

Trait Decode 

Source
pub trait Decode: Sized {
    const MIN_SIZE: usize = 0;

    // Required method
    fn decode(data: &[u8]) -> Option<(Self, usize)>;
}
Expand description

Decode a value from a byte slice in conduit’s binary wire format.

Returns the decoded value together with the number of bytes consumed, or None if the data is too short or malformed.

Provided Associated Constants§

Source

const MIN_SIZE: usize = 0

Minimum number of bytes required to attempt decoding this type.

For fixed-size types (primitives), this equals the exact encoded size. For variable-size types (String, Vec), this is the minimum (the length prefix size). Used by derived impls for an upfront bounds check.

Required Methods§

Source

fn decode(data: &[u8]) -> Option<(Self, usize)>

Attempt to decode from the start of data.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Decode for bool

Source§

const MIN_SIZE: usize = 1

Source§

fn decode(data: &[u8]) -> Option<(Self, usize)>

Source§

impl Decode for f32

Source§

const MIN_SIZE: usize

Source§

fn decode(data: &[u8]) -> Option<(Self, usize)>

Source§

impl Decode for f64

Source§

const MIN_SIZE: usize

Source§

fn decode(data: &[u8]) -> Option<(Self, usize)>

Source§

impl Decode for i8

Source§

const MIN_SIZE: usize

Source§

fn decode(data: &[u8]) -> Option<(Self, usize)>

Source§

impl Decode for i16

Source§

const MIN_SIZE: usize

Source§

fn decode(data: &[u8]) -> Option<(Self, usize)>

Source§

impl Decode for i32

Source§

const MIN_SIZE: usize

Source§

fn decode(data: &[u8]) -> Option<(Self, usize)>

Source§

impl Decode for i64

Source§

const MIN_SIZE: usize

Source§

fn decode(data: &[u8]) -> Option<(Self, usize)>

Source§

impl Decode for u8

Source§

const MIN_SIZE: usize

Source§

fn decode(data: &[u8]) -> Option<(Self, usize)>

Source§

impl Decode for u16

Source§

const MIN_SIZE: usize

Source§

fn decode(data: &[u8]) -> Option<(Self, usize)>

Source§

impl Decode for u32

Source§

const MIN_SIZE: usize

Source§

fn decode(data: &[u8]) -> Option<(Self, usize)>

Source§

impl Decode for u64

Source§

const MIN_SIZE: usize

Source§

fn decode(data: &[u8]) -> Option<(Self, usize)>

Source§

impl Decode for String

Source§

const MIN_SIZE: usize = 4

Source§

fn decode(data: &[u8]) -> Option<(Self, usize)>

Source§

impl<T: Decode> Decode for Vec<T>

Source§

const MIN_SIZE: usize = 4

Source§

fn decode(data: &[u8]) -> Option<(Self, usize)>

Implementors§