Trait bincode_core::CoreRead[][src]

pub trait CoreRead<'a> {
    type Error: Debug;
    fn fill(&mut self, buffer: &mut [u8]) -> Result<(), Self::Error>;
fn forward_str<V>(
        &mut self,
        len: usize,
        visitor: V
    ) -> Result<V::Value, Self::Error>
    where
        V: Visitor<'a>
;
fn forward_bytes<V>(
        &mut self,
        len: usize,
        visitor: V
    ) -> Result<V::Value, Self::Error>
    where
        V: Visitor<'a>
; }

A target that can be read from. This is similar to std::io::Read, but the std trait is not available in #![no_std] projects.

This trait is auto-implemented for &[u8].

Because the deserialization is done in-place, any object implementing this trait MUST return a persistent reference to the original data. This allows (de)serialization from e.g. &str and &[u8] without an allocator.

The easiest way to implement this would be by reading data into a fixed-size array and reading from there.

This trait does not support async reading yet. Reads are expected to be blocking.

Associated Types

type Error: Debug[src]

The error that this reader can encounter

Loading content...

Required methods

fn fill(&mut self, buffer: &mut [u8]) -> Result<(), Self::Error>[src]

Fills the given buffer from the reader. The input buffer MUST be completely filled. If the reader reaches end-of-file before filling the buffer an error MUST be returned.

fn forward_str<V>(
    &mut self,
    len: usize,
    visitor: V
) -> Result<V::Value, Self::Error> where
    V: Visitor<'a>, 
[src]

Forward a string slice from the reader on to the given visitor.

If allocations are not available on the system, the bytes forwarded MUST be a reference to a persistent buffer and forwarded on to visitor.visit_borrowed_str.

The forwarded slice MUST be exactly the size that is requested.

fn forward_bytes<V>(
    &mut self,
    len: usize,
    visitor: V
) -> Result<V::Value, Self::Error> where
    V: Visitor<'a>, 
[src]

Forward a byte slice from the reader on to the given visitor.

If allocations are not available on the system, the bytes forwarded MUST be a reference to a persistent buffer and forwarded on to visitor.visit_borrowed_bytes.

The forwarded slice MUST be exactly the size that is requested.

Loading content...

Implementations on Foreign Types

impl<'a> CoreRead<'a> for &'a [u8][src]

type Error = SliceReadError

Loading content...

Implementors

Loading content...