Trait preserves::value::reader::BinarySource

source ·
pub trait BinarySource<'de>: Sized {
    type Mark;

    // Required methods
    fn mark(&mut self) -> Result<Self::Mark>;
    fn restore(&mut self, mark: &Self::Mark) -> Result<()>;
    fn skip(&mut self) -> Result<()>;
    fn peek(&mut self) -> Result<u8>;
    fn readbytes(&mut self, count: usize) -> Result<Cow<'de, [u8]>>;
    fn readbytes_into(&mut self, bs: &mut [u8]) -> Result<()>;

    // Provided methods
    fn packed<N: NestedValue, Dec: DomainDecode<N::Embedded>>(
        &mut self,
        decode_embedded: Dec
    ) -> PackedReader<'de, '_, N, Dec, Self> { ... }
    fn packed_iovalues(
        &mut self
    ) -> PackedReader<'de, '_, IOValue, IOValueDomainCodec, Self> { ... }
    fn text<N: NestedValue, Dec: DomainParse<N::Embedded>>(
        &mut self,
        decode_embedded: Dec
    ) -> TextReader<'de, '_, N, Dec, Self> { ... }
    fn text_iovalues(
        &mut self
    ) -> TextReader<'de, '_, IOValue, ViaCodec<IOValueDomainCodec>, Self> { ... }
}
Expand description

Generic seekable stream of input bytes.

Required Associated Types§

source

type Mark

Allows structured backtracking to an earlier position in an input.

Required Methods§

source

fn mark(&mut self) -> Result<Self::Mark>

Retrieve a marker for the current position in the input.

source

fn restore(&mut self, mark: &Self::Mark) -> Result<()>

Seek the input to a previously-saved position.

source

fn skip(&mut self) -> Result<()>

Skip the next byte.

source

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

Returns the next byte without advancing over it.

source

fn readbytes(&mut self, count: usize) -> Result<Cow<'de, [u8]>>

Returns and consumes the next count bytes, which must all be available. Always yields exactly count bytes or an error.

source

fn readbytes_into(&mut self, bs: &mut [u8]) -> Result<()>

As BinarySource::readbytes, but uses bs as destination for the read bytes as well as taking the size of bs as the count of bytes to read.

Provided Methods§

source

fn packed<N: NestedValue, Dec: DomainDecode<N::Embedded>>( &mut self, decode_embedded: Dec ) -> PackedReader<'de, '_, N, Dec, Self>

Constructs a PackedReader that will read from self.

source

fn packed_iovalues( &mut self ) -> PackedReader<'de, '_, IOValue, IOValueDomainCodec, Self>

Constructs a PackedReader that will read IOValues from self.

source

fn text<N: NestedValue, Dec: DomainParse<N::Embedded>>( &mut self, decode_embedded: Dec ) -> TextReader<'de, '_, N, Dec, Self>

Constructs a TextReader that will read from self.

source

fn text_iovalues( &mut self ) -> TextReader<'de, '_, IOValue, ViaCodec<IOValueDomainCodec>, Self>

Constructs a TextReader that will read IOValues from self.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<'de> BinarySource<'de> for BytesBinarySource<'de>

§

type Mark = usize

source§

impl<'de, 'src, N: NestedValue, Dec: DomainDecode<N::Embedded>, S: BinarySource<'de>> BinarySource<'de> for PackedReader<'de, 'src, N, Dec, S>

§

type Mark = <S as BinarySource<'de>>::Mark

source§

impl<'de, R: Read + Seek> BinarySource<'de> for IOBinarySource<R>

§

type Mark = u64