Struct LiveDataReader

Source
pub struct LiveDataReader<R>
where R: Read,
{ /* private fields */ }
Expand description

Allows reading Data variants from a Read trait object.

§Examples

use resol_vbus::{FileListReader, LiveDataReader};

let files: Vec<_> = std::env::args().skip(1).collect();

let flr = FileListReader::new(files);

let mut ldr = LiveDataReader::new(0, flr);

while let Some(data) = ldr.read_data().unwrap() {
    // process the data
    println!("{}", data.id_string());
}

Implementations§

Source§

impl<R> LiveDataReader<R>
where R: Read,

Source

pub fn new(channel: u8, reader: R) -> LiveDataReader<R>

Constructs a LiveDataReader.

Source

pub fn read_bytes(&mut self) -> Result<Option<&[u8]>, Error>

Read from the stream until a valid blob of data is found.

Source

pub fn read_data(&mut self) -> Result<Option<Data>, Error>

Read from the stream until a valid Data variant can be decoded.

Trait Implementations§

Source§

impl<R> AsMut<R> for LiveDataReader<R>
where R: Read,

Source§

fn as_mut(&mut self) -> &mut R

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<R> AsRef<R> for LiveDataReader<R>
where R: Read,

Source§

fn as_ref(&self) -> &R

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<R> Debug for LiveDataReader<R>
where R: Debug + Read,

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<R> Freeze for LiveDataReader<R>
where R: Freeze,

§

impl<R> RefUnwindSafe for LiveDataReader<R>
where R: RefUnwindSafe,

§

impl<R> Send for LiveDataReader<R>
where R: Send,

§

impl<R> Sync for LiveDataReader<R>
where R: Sync,

§

impl<R> Unpin for LiveDataReader<R>
where R: Unpin,

§

impl<R> UnwindSafe for LiveDataReader<R>
where R: UnwindSafe,

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.