pub struct TagStructReader<'a> { /* private fields */ }Expand description
A streaming reader for tagstruct-encoded data.
Implementations§
Source§impl<'a> TagStructReader<'a>
impl<'a> TagStructReader<'a>
Sourcepub fn new(inner: &'a mut dyn BufRead, protocol_version: u16) -> Self
pub fn new(inner: &'a mut dyn BufRead, protocol_version: u16) -> Self
Creates a tagstruct reader from a BufRead instance.
Sourcepub fn read_tag(&mut self) -> Result<Tag, ProtocolError>
pub fn read_tag(&mut self) -> Result<Tag, ProtocolError>
Reads a tag from the stream.
Sourcepub fn read_u8(&mut self) -> Result<u8, ProtocolError>
pub fn read_u8(&mut self) -> Result<u8, ProtocolError>
Reads a single byte.
Sourcepub fn read_u32(&mut self) -> Result<u32, ProtocolError>
pub fn read_u32(&mut self) -> Result<u32, ProtocolError>
Reads an unsigned 32-bit integer.
Sourcepub fn read_u64(&mut self) -> Result<u64, ProtocolError>
pub fn read_u64(&mut self) -> Result<u64, ProtocolError>
Reads an unsigned 64-bit integer.
Sourcepub fn read_i64(&mut self) -> Result<i64, ProtocolError>
pub fn read_i64(&mut self) -> Result<i64, ProtocolError>
Reads a signed 64-bit integer.
Sourcepub fn read_bool(&mut self) -> Result<bool, ProtocolError>
pub fn read_bool(&mut self) -> Result<bool, ProtocolError>
Reads a boolean value.
Sourcepub fn read_usec(&mut self) -> Result<u64, ProtocolError>
pub fn read_usec(&mut self) -> Result<u64, ProtocolError>
Reads a “usec” value, which is a 64-bit unsigned integer representing a number of microseconds.
Sourcepub fn read_timeval(&mut self) -> Result<SystemTime, ProtocolError>
pub fn read_timeval(&mut self) -> Result<SystemTime, ProtocolError>
Reads a timestamp, or “timeval”, with microsecond precision.
Sourcepub fn read_arbitrary(&mut self) -> Result<Vec<u8>, ProtocolError>
pub fn read_arbitrary(&mut self) -> Result<Vec<u8>, ProtocolError>
Reads an “arbitrary”, a byte blob. Allocates a vec.
Sourcepub fn read_arbitrary_unprefixed(
&mut self,
len: u32,
) -> Result<Vec<u8>, ProtocolError>
pub fn read_arbitrary_unprefixed( &mut self, len: u32, ) -> Result<Vec<u8>, ProtocolError>
Reads an “arbitrary” without length prefix.
Sourcepub fn read_string(&mut self) -> Result<Option<CString>, ProtocolError>
pub fn read_string(&mut self) -> Result<Option<CString>, ProtocolError>
Reads a null-terminated string (which may be a special null string tag).
Note that strings in a tagstruct aren’t necessarily encoded in UTF-8.
Sourcepub fn read_string_non_null(&mut self) -> Result<CString, ProtocolError>
pub fn read_string_non_null(&mut self) -> Result<CString, ProtocolError>
Reads a null-terminated string.
Sourcepub fn read_index(&mut self) -> Result<Option<u32>, ProtocolError>
pub fn read_index(&mut self) -> Result<Option<u32>, ProtocolError>
Reads a u32, and checks it against PA_INVALID_INDEX (-1).
Sourcepub fn read_enum<T: FromPrimitive>(&mut self) -> Result<T, ProtocolError>
pub fn read_enum<T: FromPrimitive>(&mut self) -> Result<T, ProtocolError>
Reads a u32 and checks that it is valid for the given enum.
Sourcepub fn read<T: TagStructRead>(&mut self) -> Result<T, ProtocolError>
pub fn read<T: TagStructRead>(&mut self) -> Result<T, ProtocolError>
Reads a value which implements TagStructRead.
Sourcepub fn has_data_left(&mut self) -> Result<bool, ProtocolError>
pub fn has_data_left(&mut self) -> Result<bool, ProtocolError>
Returns whether there is any data left in the input stream.