pub trait ChiselSource {
    type Error;
    // Required methods
    fn read_exact(
        &mut self,
        buffer: &mut [u8],
    ) -> Result<(), ChiselSourceError<Self::Error>>;
    fn read_until(
        &mut self,
        byte: u8,
        into: &mut Vec<u8>,
    ) -> Result<ReadUntilStopReason, Self::Error>;
    fn skip(
        &mut self,
        how_many: usize,
    ) -> Result<(), ChiselSourceError<Self::Error>>;
}Expand description
A “source” for chiseling bytes out of.
This is analogous to the standard library Read and/or BufRead traits, but specialized for
chiseling operations.
Required Associated Types§
Required Methods§
Sourcefn read_exact(
    &mut self,
    buffer: &mut [u8],
) -> Result<(), ChiselSourceError<Self::Error>>
 
fn read_exact( &mut self, buffer: &mut [u8], ) -> Result<(), ChiselSourceError<Self::Error>>
Reads the exact number of bytes to fill buffer.
§Errors
If an end-of-input condition occurs before completely filling the buffer, ChiselSourceError::EndOfInput is returned.
If any other error occurs while reading, this function immediately returns with ChiselSourceError::Underlying(_).
If any error is returned, the contents of buffer are unspecified.
How many bytes were read is also unspecified, except that at most buffer.len() bytes are read.
Sourcefn read_until(
    &mut self,
    byte: u8,
    into: &mut Vec<u8>,
) -> Result<ReadUntilStopReason, Self::Error>
 
fn read_until( &mut self, byte: u8, into: &mut Vec<u8>, ) -> Result<ReadUntilStopReason, Self::Error>
Reads until the given delimiter byte is found or end-of-input occurs.
If end-of-input occurs before the delimiter byte is found, ReadUntilStopReason::EndOfInput is returned.
Otherwise, ReadUntilStopReason::Delimiter is returned. The found delimiter is not added to into.
§Errors
If an error occurs while reading, this function immediately returns with ChiselSourceError::Underlying(_).
If this occurs, the contents of into are unspecified. How many bytes were read is also unspecified, with no restrictions.
Note that end-of-input conditions are not errors, and result in Ok(ReadUntilStopReason::EndOfInput).
Sourcefn skip(
    &mut self,
    how_many: usize,
) -> Result<(), ChiselSourceError<Self::Error>>
 
fn skip( &mut self, how_many: usize, ) -> Result<(), ChiselSourceError<Self::Error>>
Skips some number of bytes of the input.
This is usually used for padding or alignment.
§Errors
If end-of-input condition occurs before how_many bytes are skipped, ChiselSourceError::EndOfInput is returned.
If any other error occurs while skipping, this function immediately returns with ``ChiselSourceError::Underlying(_)`.
If any error is returned, it is unspecified how many bytes are skipped, except that at most how_many
bytes are be skipped.
Implementations on Foreign Types§
Source§impl ChiselSource for &[u8]
 
impl ChiselSource for &[u8]
type Error = Infallible
fn read_exact( &mut self, buffer: &mut [u8], ) -> Result<(), ChiselSourceError<Self::Error>>
fn read_until( &mut self, byte: u8, into: &mut Vec<u8>, ) -> Result<ReadUntilStopReason, Self::Error>
fn skip( &mut self, how_many: usize, ) -> Result<(), ChiselSourceError<Self::Error>>
Implementors§
Source§impl<'a, R: BufRead> ChiselSource for ChiselSourceBufRead<'a, R>
Available on crate feature std only. 
impl<'a, R: BufRead> ChiselSource for ChiselSourceBufRead<'a, R>
std only.Source§impl<'a, R: Read> ChiselSource for ChiselSourceRead<'a, R>
Available on crate feature std only. 
impl<'a, R: Read> ChiselSource for ChiselSourceRead<'a, R>
std only.