Struct Parser

Source
pub struct Parser<'a, D: VEDirectData, E: Events<D>> { /* private fields */ }
Expand description

Parser is fed with bytes, and sends events to the supplied listener object.

§Example

use vedirect::{Events, Parser};

struct ExampleListener;
 
impl Events<vedirect::Bmv700> for ExampleListener {
    fn on_complete_block(&mut self, block: vedirect::Bmv700) {
        println!("Mapped data {:#?}", &block);
    }
}
 
let mut listener = ExampleListener {};
let mut parser = Parser::new(&mut listener);
parser.feed(b"\r\nPID\t0xA053\r\nFW\t159").unwrap();

Implementations§

Source§

impl<'a, E: Events<D>, D: VEDirectData> Parser<'a, D, E>

Source

pub fn new(listener: &'a mut E) -> Self

Create parser

Source

pub fn feed(&mut self, data: &[u8]) -> Result<(), VEError>

Supply bytes from device to parser. See example on Parser or the read_serial example for details on how to use.

Auto Trait Implementations§

§

impl<'a, D, E> Freeze for Parser<'a, D, E>

§

impl<'a, D, E> RefUnwindSafe for Parser<'a, D, E>

§

impl<'a, D, E> Send for Parser<'a, D, E>
where E: Send + Sync, D: Send,

§

impl<'a, D, E> Sync for Parser<'a, D, E>
where E: Sync, D: Sync,

§

impl<'a, D, E> Unpin for Parser<'a, D, E>
where D: Unpin,

§

impl<'a, D, E> !UnwindSafe for Parser<'a, D, E>

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.