Skip to main content

BinarySource

Trait 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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

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

Source§

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

Source§

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

Source§

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