pub trait VectoredReadRef {
    fn read_vectored_ref<'a>(
        curs: &mut VectoredCursor<'a>,
        size: usize
    ) -> Result<&'a Self, WireError>; }
Expand description

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

A type that implements this trait guarantees that it can be constructed using a given number of bytes from the provided VectoredCursor. If the bytes contained on the vectored 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§

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 vectored buffer that it references, though it may outlive the VectoredReader 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

Implementations on Foreign Types§

Implementors§