Struct TagStructReader

Source
pub struct TagStructReader<'a> { /* private fields */ }
Expand description

A streaming reader for tagstruct-encoded data.

Implementations§

Source§

impl<'a> TagStructReader<'a>

Source

pub fn new(inner: &'a mut dyn BufRead, protocol_version: u16) -> Self

Creates a tagstruct reader from a BufRead instance.

Source

pub fn read_tag(&mut self) -> Result<Tag, ProtocolError>

Reads a tag from the stream.

Source

pub fn read_u8(&mut self) -> Result<u8, ProtocolError>

Reads a single byte.

Source

pub fn read_u32(&mut self) -> Result<u32, ProtocolError>

Reads an unsigned 32-bit integer.

Source

pub fn read_u64(&mut self) -> Result<u64, ProtocolError>

Reads an unsigned 64-bit integer.

Source

pub fn read_i64(&mut self) -> Result<i64, ProtocolError>

Reads a signed 64-bit integer.

Source

pub fn read_bool(&mut self) -> Result<bool, ProtocolError>

Reads a boolean value.

Source

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.

Source

pub fn read_timeval(&mut self) -> Result<SystemTime, ProtocolError>

Reads a timestamp, or “timeval”, with microsecond precision.

Source

pub fn read_arbitrary(&mut self) -> Result<Vec<u8>, ProtocolError>

Reads an “arbitrary”, a byte blob. Allocates a vec.

Source

pub fn read_arbitrary_unprefixed( &mut self, len: u32, ) -> Result<Vec<u8>, ProtocolError>

Reads an “arbitrary” without length prefix.

Source

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.

Source

pub fn read_string_non_null(&mut self) -> Result<CString, ProtocolError>

Reads a null-terminated string.

Source

pub fn read_index(&mut self) -> Result<Option<u32>, ProtocolError>

Reads a u32, and checks it against PA_INVALID_INDEX (-1).

Source

pub fn read_enum<T: FromPrimitive>(&mut self) -> Result<T, ProtocolError>

Reads a u32 and checks that it is valid for the given enum.

Source

pub fn read<T: TagStructRead>(&mut self) -> Result<T, ProtocolError>

Reads a value which implements TagStructRead.

Source

pub fn has_data_left(&mut self) -> Result<bool, ProtocolError>

Returns whether there is any data left in the input stream.

Trait Implementations§

Source§

impl Debug for TagStructReader<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for TagStructReader<'a>

§

impl<'a> !RefUnwindSafe for TagStructReader<'a>

§

impl<'a> !Send for TagStructReader<'a>

§

impl<'a> !Sync for TagStructReader<'a>

§

impl<'a> Unpin for TagStructReader<'a>

§

impl<'a> !UnwindSafe for TagStructReader<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.