pub struct CommandParser<'a, D> { /* private fields */ }
Expand description
use at_commands::parser::CommandParser;
let (x, y, z) = CommandParser::parse(b"+SYSGPIOREAD:654,\"true\",-65154\r\nOK\r\n")
.expect_identifier(b"+SYSGPIOREAD:")
.expect_int_parameter()
.expect_string_parameter()
.expect_int_parameter()
.expect_identifier(b"\r\nOK\r\n")
.finish()
.unwrap();
assert_eq!(x, 654);
assert_eq!(y, "true");
assert_eq!(z, -65154);
let (w,) = CommandParser::parse(b"+STATUS: READY\r\nOK\r\n")
.expect_identifier(b"+STATUS: ")
.expect_raw_string()
.expect_identifier(b"\r\nOK\r\n")
.finish()
.unwrap();
assert_eq!(w, "READY");
Implementations§
Source§impl<'a> CommandParser<'a, ()>
impl<'a> CommandParser<'a, ()>
Sourcepub fn parse(buffer: &'a [u8]) -> CommandParser<'a, ()>
pub fn parse(buffer: &'a [u8]) -> CommandParser<'a, ()>
Start parsing the command
Source§impl<'a, D> CommandParser<'a, D>
impl<'a, D> CommandParser<'a, D>
Sourcepub fn expect_identifier(self, identifier: &[u8]) -> Self
pub fn expect_identifier(self, identifier: &[u8]) -> Self
Tries reading an identifier
Sourcepub fn expect_optional_identifier(self, identifier: &[u8]) -> Self
pub fn expect_optional_identifier(self, identifier: &[u8]) -> Self
Tries reading an optional identifier.
Sourcepub fn finish(self) -> Result<D, ParseError>
pub fn finish(self) -> Result<D, ParseError>
Finish parsing the command and get the results
Source§impl<'a, D: TupleConcat<i32>> CommandParser<'a, D>
impl<'a, D: TupleConcat<i32>> CommandParser<'a, D>
Sourcepub fn expect_int_parameter(self) -> CommandParser<'a, D::Out>
pub fn expect_int_parameter(self) -> CommandParser<'a, D::Out>
Tries reading an int parameter
Source§impl<'a, D: TupleConcat<&'a str>> CommandParser<'a, D>
impl<'a, D: TupleConcat<&'a str>> CommandParser<'a, D>
Sourcepub fn expect_string_parameter(self) -> CommandParser<'a, D::Out>
pub fn expect_string_parameter(self) -> CommandParser<'a, D::Out>
Tries reading a string parameter
Sourcepub fn expect_raw_string(self) -> CommandParser<'a, D::Out>
pub fn expect_raw_string(self) -> CommandParser<'a, D::Out>
Tries reading a non-parameter, non-quoted string
Source§impl<'a, D: TupleConcat<Option<i32>>> CommandParser<'a, D>
impl<'a, D: TupleConcat<Option<i32>>> CommandParser<'a, D>
Sourcepub fn expect_optional_int_parameter(self) -> CommandParser<'a, D::Out>
pub fn expect_optional_int_parameter(self) -> CommandParser<'a, D::Out>
Tries reading an int parameter
Source§impl<'a, D: TupleConcat<Option<&'a str>>> CommandParser<'a, D>
impl<'a, D: TupleConcat<Option<&'a str>>> CommandParser<'a, D>
Sourcepub fn expect_optional_string_parameter(self) -> CommandParser<'a, D::Out>
pub fn expect_optional_string_parameter(self) -> CommandParser<'a, D::Out>
Tries reading a string parameter
Sourcepub fn expect_optional_raw_string(self) -> CommandParser<'a, D::Out>
pub fn expect_optional_raw_string(self) -> CommandParser<'a, D::Out>
Tries reading a non-parameter, non-quoted string
Auto Trait Implementations§
impl<'a, D> Freeze for CommandParser<'a, D>where
D: Freeze,
impl<'a, D> RefUnwindSafe for CommandParser<'a, D>where
D: RefUnwindSafe,
impl<'a, D> Send for CommandParser<'a, D>where
D: Send,
impl<'a, D> Sync for CommandParser<'a, D>where
D: Sync,
impl<'a, D> Unpin for CommandParser<'a, D>where
D: Unpin,
impl<'a, D> UnwindSafe for CommandParser<'a, D>where
D: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more