Trait WireReadRef

Source
pub trait WireReadRef {
    // Required method
    fn read_wire_ref<'a>(
        curs: &mut WireCursor<'a>,
        size: usize,
    ) -> Result<&'a Self, WireError>;
}
Expand description

Deserialization to an immutable reference of a data type from the wire.

A type that implements this trait guarantees that it can be constructed using a given number of bytes from the provided WireCursor. If the bytes contained on the wire cannot be converted into a reference of a valid instance of the object, an error will be returned instead of the reference.

Required Methods§

Source

fn read_wire_ref<'a>( curs: &mut WireCursor<'a>, size: usize, ) -> Result<&'a Self, WireError>

Consumes exactly size bytes from curs and returns an immutable reference of the specified type, or returns a WireError on failure.

The returned reference must not outlive the lifetime of the buffer that it references, though it may outlive the WireReader used to construct it.

The generic boolean E designates the intended endianness of the data being read. If E is set to true, then the data will be deserialized in big endian format; if false, it will be deserialized in little endian.

§Errors

WireError::InsufficientBytes - less than size bytes remained on the cursor.

WireError::InvalidData - the bytes retrieved from curs could not be used to construct a valid reference of the type.

WireError::Internal - an internal error occurred in the wire-rs library

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 WireReadRef for str

Source§

fn read_wire_ref<'a>( curs: &mut WireCursor<'a>, size: usize, ) -> Result<&'a Self, WireError>

Source§

impl WireReadRef for [u8]

Source§

fn read_wire_ref<'a>( curs: &mut WireCursor<'a>, size: usize, ) -> Result<&'a Self, WireError>

Implementors§