Trait serde_amqp::read::Read

source ·
pub trait Read<'de>: Sealed {
    // Required methods
    fn peek(&mut self) -> Option<u8>;
    fn next(&mut self) -> Option<u8>;
    fn peek_bytes(&mut self, n: usize) -> Option<&[u8]>;
    fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>;
    fn forward_read_bytes<V>(
        &mut self,
        len: usize,
        visitor: V,
    ) -> Result<V::Value, Error>
       where V: Visitor<'de>;
    fn forward_read_str<V>(
        &mut self,
        len: usize,
        visitor: V,
    ) -> Result<V::Value, Error>
       where V: Visitor<'de>;

    // Provided methods
    fn read_const_bytes<const N: usize>(&mut self) -> Option<[u8; N]> { ... }
    fn read_bytes(&mut self, n: usize) -> Option<Vec<u8>> { ... }
}
Expand description

A custom Read trait for internal use

Required Methods§

source

fn peek(&mut self) -> Option<u8>

Peek the next byte without consuming

source

fn next(&mut self) -> Option<u8>

Read the next byte

source

fn peek_bytes(&mut self, n: usize) -> Option<&[u8]>

Peek n number of bytes without consuming

source

fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>

Read to buffer

source

fn forward_read_bytes<V>( &mut self, len: usize, visitor: V, ) -> Result<V::Value, Error>
where V: Visitor<'de>,

Forward bytes to visitor

source

fn forward_read_str<V>( &mut self, len: usize, visitor: V, ) -> Result<V::Value, Error>
where V: Visitor<'de>,

Forward str to visitor

Provided Methods§

source

fn read_const_bytes<const N: usize>(&mut self) -> Option<[u8; N]>

Read n bytes

Prefered to use this when the size is small and can be stack allocated

source

fn read_bytes(&mut self, n: usize) -> Option<Vec<u8>>

Consuming n number of bytes

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<'de, R: Read + 'de> Read<'de> for IoReader<R>

source§

impl<'s> Read<'s> for SliceReader<'s>