Skip to main content

BytesExt

Trait BytesExt 

Source
pub trait BytesExt {
    // Required methods
    fn read_cstr(&mut self) -> Result<String>;
    fn read_i32_be(&mut self) -> Result<i32>;
    fn read_i16_be(&mut self) -> Result<i16>;
}
Expand description

Extension trait for Bytes operations

Required Methods§

Source

fn read_cstr(&mut self) -> Result<String>

Read a null-terminated string

§Errors

Returns io::Error with InvalidData if no null terminator is found or the bytes before the terminator are not valid UTF-8.

Source

fn read_i32_be(&mut self) -> Result<i32>

Read a 32-bit big-endian integer

§Errors

Returns io::Error with UnexpectedEof if fewer than 4 bytes remain.

Source

fn read_i16_be(&mut self) -> Result<i16>

Read a 16-bit big-endian integer

§Errors

Returns io::Error with UnexpectedEof if fewer than 2 bytes remain.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl BytesExt for Bytes

Source§

fn read_cstr(&mut self) -> Result<String>

Source§

fn read_i32_be(&mut self) -> Result<i32>

Source§

fn read_i16_be(&mut self) -> Result<i16>

Implementors§