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§
Sourcefn shrink_unchecked(&mut self, len: usize)
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§
Sourcefn ntohs_unchecked(&self, offset: usize) -> u16
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.
Sourcefn ntohl_unchecked(&self, offset: usize) -> u32
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.