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§
Required Methods§
sourcefn mark(&mut self) -> Result<Self::Mark>
fn mark(&mut self) -> Result<Self::Mark>
Retrieve a marker for the current position in the input.
sourcefn restore(&mut self, mark: &Self::Mark) -> Result<()>
fn restore(&mut self, mark: &Self::Mark) -> Result<()>
Seek the input to a previously-saved position.
sourcefn readbytes(&mut self, count: usize) -> Result<Cow<'de, [u8]>>
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.
sourcefn readbytes_into(&mut self, bs: &mut [u8]) -> Result<()>
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§
sourcefn packed<N: NestedValue, Dec: DomainDecode<N::Embedded>>(
&mut self,
decode_embedded: Dec
) -> PackedReader<'de, '_, N, Dec, Self>
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
.
sourcefn packed_iovalues(
&mut self
) -> PackedReader<'de, '_, IOValue, IOValueDomainCodec, Self>
fn packed_iovalues( &mut self ) -> PackedReader<'de, '_, IOValue, IOValueDomainCodec, Self>
Constructs a PackedReader that will read IOValues from self
.
sourcefn text<N: NestedValue, Dec: DomainParse<N::Embedded>>(
&mut self,
decode_embedded: Dec
) -> TextReader<'de, '_, N, Dec, Self>
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
.
sourcefn text_iovalues(
&mut self
) -> TextReader<'de, '_, IOValue, ViaCodec<IOValueDomainCodec>, Self>
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.