Struct atat::digest::AtDigester

source ·
pub struct AtDigester<P: Parser> { /* private fields */ }
Expand description

A Digester that tries to implement the basic AT standard. This digester should work for most usecases of ATAT.

Implements a request-response AT digester capable of working with or without AT echo enabled.

Buffer can contain (‘…’ meaning arbitrary data):

  • ‘…AT<CMD>\r\r\n<RESPONSE>\r\n<RESPONSE CODE>\r\n…’ (Echo enabled)
  • ‘…AT<CMD>\r\r\n<CMD>: <PARAMETERS>\r\n<RESPONSE CODE>\r\n…’ (Echo enabled)
  • ‘…AT<CMD>\r\r\n<RESPONSE CODE>\r\n…’ (Echo enabled)
  • ‘…<CMD>:<PARAMETERS>\r\n<RESPONSE CODE>\r\n…’ (Echo disabled)
  • ‘…<RESPONSE>\r\n<RESPONSE CODE>\r\n…’ (Echo disabled)
  • ‘…<URC>\r\n…’ (Unsolicited response code)
  • ‘…<URC>:<PARAMETERS>\r\n…’ (Unsolicited response code)
  • ‘…<PROMPT>’ (Prompt for data)

Goal of the digester is to extract these into:

  • DigestResult::Response(Result\<RESPONSE>)
  • DigestResult::Urc(\<URC>)
  • DigestResult::Prompt(\<CHAR>)
  • DigestResult::None

Usually <RESPONSE CODE> is one of [‘OK’, ‘ERROR’, ‘CME ERROR: <NUMBER/STRING>’, ‘CMS ERROR: <NUMBER/STRING>’], but can be others as well depending on manufacturer.

Usually <PROMPT> can be one of [‘>’, ‘@’], and is command specific and only valid for few selected commands.

Implementations§

source§

impl<P: Parser> AtDigester<P>

source

pub const fn new() -> Self

source

pub fn with_custom_success( self, f: fn(_: &[u8]) -> Result<(&[u8], usize), ParseError> ) -> Self

source

pub fn with_custom_error( self, f: fn(_: &[u8]) -> Result<(&[u8], usize), ParseError> ) -> Self

source

pub fn with_custom_prompt( self, f: fn(_: &[u8]) -> Result<(u8, usize), ParseError> ) -> Self

Trait Implementations§

source§

impl<P: Parser> Default for AtDigester<P>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<P: Parser> Digester for AtDigester<P>

source§

fn digest<'a>(&mut self, input: &'a [u8]) -> (DigestResult<'a>, usize)

Auto Trait Implementations§

§

impl<P> Freeze for AtDigester<P>

§

impl<P> RefUnwindSafe for AtDigester<P>
where P: RefUnwindSafe,

§

impl<P> Send for AtDigester<P>
where P: Send,

§

impl<P> Sync for AtDigester<P>
where P: Sync,

§

impl<P> Unpin for AtDigester<P>
where P: Unpin,

§

impl<P> UnwindSafe for AtDigester<P>
where P: 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> Same for T

§

type Output = T

Should always be Self
source§

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

§

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>,

§

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.