[][src]Struct at_commands::builder::CommandBuilder

pub struct CommandBuilder<'a, STAGE> { /* fields omitted */ }

CommandBuilder

A builder struct for AT Commands

Summary

This can be used to build:

  • A test command in the form AT{name}=?
  • A query command in the form AT{name}?
  • A set command in the form AT{name}={param},{param},{param}
  • An execute command in the form AT{name}

Example

use at_commands::builder::CommandBuilder;

let mut buffer = [0; 128];

// Make a query command
let result = CommandBuilder::create_query(&mut buffer, true)
    .named("+MYQUERY")
    .finish()
    .unwrap();

// Buffer now contains "AT+MYQUERY?"
// Copy or DMA the resulting slice to the device.

// Make a set command
let result = CommandBuilder::create_set(&mut buffer, false)
    .named("+MYSET")
    .with_int_parameter(42)
    .finish()
    .unwrap();

// Buffer now contains "+MYSET=42"
// Copy or DMA the resulting slice to the device.

Implementations

impl<'a> CommandBuilder<'a, Uninitialized>[src]

pub fn create_test(
    buffer: &'a mut [u8],
    at_prefix: bool
) -> CommandBuilder<'a, Initialized<Test>>
[src]

Creates a builder for a test command.

The given buffer is used to build the command in and must be big enough to contain it.

pub fn create_query(
    buffer: &'a mut [u8],
    at_prefix: bool
) -> CommandBuilder<'a, Initialized<Query>>
[src]

Creates a builder for a query command.

The given buffer is used to build the command in and must be big enough to contain it.

pub fn create_set(
    buffer: &'a mut [u8],
    at_prefix: bool
) -> CommandBuilder<'a, Initialized<Set>>
[src]

Creates a builder for a set command.

The given buffer is used to build the command in and must be big enough to contain it.

pub fn create_execute(
    buffer: &'a mut [u8],
    at_prefix: bool
) -> CommandBuilder<'a, Initialized<Execute>>
[src]

Creates a builder for an test execute.

The given buffer is used to build the command in and must be big enough to contain it.

impl<'a, N: Nameable> CommandBuilder<'a, Initialized<N>>[src]

pub fn named(self, name: &str) -> CommandBuilder<'a, N>[src]

Set the name of the command.

impl<'a> CommandBuilder<'a, Set>[src]

pub fn with_int_parameter(self, value: i32) -> Self[src]

Add an integer parameter.

pub fn with_string_parameter(self, value: &str) -> Self[src]

Add a string parameter

impl<'a, F: Finishable> CommandBuilder<'a, F>[src]

pub fn finish(self) -> Result<&'a [u8], usize>[src]

Finishes the builder.

When Ok, it returns a slice with the built command. The slice points to the same memory as the buffer, but is only as long as is required to contain the command.

The command length is thus the length of the slice.

If the buffer was not long enough, then an Err is returned with the size that was required for it to succeed.

Auto Trait Implementations

impl<'a, STAGE> Send for CommandBuilder<'a, STAGE> where
    STAGE: Send

impl<'a, STAGE> Sync for CommandBuilder<'a, STAGE> where
    STAGE: Sync

impl<'a, STAGE> Unpin for CommandBuilder<'a, STAGE> where
    STAGE: Unpin

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.