pub trait Read<'a> {
// Required methods
fn next(&mut self) -> Option<Result<u8>>;
fn peek(&mut self) -> Option<Result<u8>>;
fn byte_offset(&self) -> usize;
fn parse_byte_str<'b>(
&'b mut self,
buf: &'b mut Vec<u8>,
) -> Result<Ref<'a, 'b, [u8]>>;
fn parse_raw_integer<'b>(
&'b mut self,
buf: &'b mut Vec<u8>,
) -> Result<Ref<'a, 'b, [u8]>>;
fn parse_raw_byte_str<'b>(
&mut self,
buf: &'b mut Vec<u8>,
) -> Result<Ref<'a, 'b, [u8]>>;
fn parse_raw_list<'b>(
&'b mut self,
buf: &'b mut Vec<u8>,
) -> Result<Ref<'a, 'b, [u8]>>;
fn parse_raw_dict<'b>(
&'b mut self,
buf: &'b mut Vec<u8>,
) -> Result<Ref<'a, 'b, [u8]>>;
}Expand description
Trait used by the de::Deserializer to read bytes.
Required Methods§
Sourcefn peek(&mut self) -> Option<Result<u8>>
fn peek(&mut self) -> Option<Result<u8>>
Returns the next byte but does not consume.
Repeated peeks (with no next() call) should return the same byte.
Sourcefn byte_offset(&self) -> usize
fn byte_offset(&self) -> usize
Returns the position in the stream of bytes.
Sourcefn parse_byte_str<'b>(
&'b mut self,
buf: &'b mut Vec<u8>,
) -> Result<Ref<'a, 'b, [u8]>>
fn parse_byte_str<'b>( &'b mut self, buf: &'b mut Vec<u8>, ) -> Result<Ref<'a, 'b, [u8]>>
Returns the next slice of data for the given length.
If all of the data is already read and available to borrowed against, the returned result could be a reference to the original underlying data.
If the data is not already available and needs to be buffered, the data could be added to the given buffer parameter and a borrowed slice from the buffer could be returned.
§Errors
Errors include:
- malformatted input
- end of file
Sourcefn parse_raw_integer<'b>(
&'b mut self,
buf: &'b mut Vec<u8>,
) -> Result<Ref<'a, 'b, [u8]>>
fn parse_raw_integer<'b>( &'b mut self, buf: &'b mut Vec<u8>, ) -> Result<Ref<'a, 'b, [u8]>>
Consumes and returns the next integer raw encoding.
The buffer can be used as a temporary buffer for storing any bytes which need to be read. The contents of the buffer is not guaranteed before or after the method is called.
§Errors
Errors include:
- malformatted input
- end of file
Sourcefn parse_raw_byte_str<'b>(
&mut self,
buf: &'b mut Vec<u8>,
) -> Result<Ref<'a, 'b, [u8]>>
fn parse_raw_byte_str<'b>( &mut self, buf: &'b mut Vec<u8>, ) -> Result<Ref<'a, 'b, [u8]>>
Consumes and returns the next byte string raw encoding.
The buffer can be used as a temporary buffer for storing any bytes which need to be read. The contents of the buffer is not guaranteed before or after the method is called.
§Errors
Errors include:
- malformatted input
- end of file
Sourcefn parse_raw_list<'b>(
&'b mut self,
buf: &'b mut Vec<u8>,
) -> Result<Ref<'a, 'b, [u8]>>
fn parse_raw_list<'b>( &'b mut self, buf: &'b mut Vec<u8>, ) -> Result<Ref<'a, 'b, [u8]>>
Consumes and returns the next list raw encoding.
The buffer can be used as a temporary buffer for storing any bytes which need to be read. The contents of the buffer is not guaranteed before or after the method is called.
§Errors
Errors include:
- malformatted input
- end of file
Sourcefn parse_raw_dict<'b>(
&'b mut self,
buf: &'b mut Vec<u8>,
) -> Result<Ref<'a, 'b, [u8]>>
fn parse_raw_dict<'b>( &'b mut self, buf: &'b mut Vec<u8>, ) -> Result<Ref<'a, 'b, [u8]>>
Consumes and returns the next dictionary raw encoding.
The buffer can be used as a temporary buffer for storing any bytes which need to be read. The contents of the buffer is not guaranteed before or after the method is called.
§Errors
Errors include:
- malformatted input
- end of file