NetworkBytes

Trait NetworkBytes 

Source
pub trait NetworkBytes: Deref<Target = [u8]> {
    // Required method
    fn shrink_unchecked(&mut self, len: usize);

    // Provided methods
    fn ntohs_unchecked(&self, offset: usize) -> u16 { ... }
    fn ntohl_unchecked(&self, offset: usize) -> u32 { ... }
}
Expand description

Represents an immutable view into a sequence of bytes which stands for different values packed together using network byte ordering.

Required Methods§

Source

fn shrink_unchecked(&mut self, len: usize)

Shrinks the current slice to the given len.

Does not check whether len is actually smaller than self.len().

§Panics

This method will panic if len is greater than self.len().

Provided Methods§

Source

fn ntohs_unchecked(&self, offset: usize) -> u16

Reads an u16 value from the specified offset, converting it to host byte ordering.

§Panics

This method will panic if offset is invalid.

Source

fn ntohl_unchecked(&self, offset: usize) -> u32

Reads an u32 value from the specified offset, converting it to host byte ordering.

§Panics

This method will panic if offset is invalid.

Implementations on Foreign Types§

Source§

impl NetworkBytes for &[u8]

Source§

fn shrink_unchecked(&mut self, len: usize)

Source§

impl NetworkBytes for &mut [u8]

Source§

fn shrink_unchecked(&mut self, len: usize)

Implementors§