Skip to main content

TxQueue

Struct TxQueue 

Source
pub struct TxQueue<'c, 'd, E: Encoder> { /* private fields */ }
Expand description

A queue to efficiently transmit multiple signals, reusing encoders when possible.

The driver has an internal queue from which it will copy the signals into the peripheral memory. The signal and encoder must be valid until the transmission is done, which can not be guaranteed when directly using the queue through TxChannelDriver::start_send.

This type provides a safe interface to fill up the queue, reusing encoders when possible. To do this, it keeps an allocated buffer for each encoder, to which the signal will be copied before starting the transmission. This ensures that both the signal and encoder are valid until the transmission is done.

§Drop behavior

When the TxQueue is dropped, it will wait for all transmissions to finish. This ensures that the internal buffers are not dropped while they are still in use by the peripheral.

Implementations§

Source§

impl<'c, 'd, E: Encoder> TxQueue<'c, 'd, E>

Source

pub fn channel(&mut self) -> &mut TxChannelDriver<'d>

Returns a mutable reference to the channel this queue is using.

Source§

impl<'c, 'd, E: Encoder> TxQueue<'c, 'd, E>

Source

pub fn push( &mut self, signal: &[E::Item], config: &TransmitConfig, ) -> Result<(), EspError>
where E::Item: Clone,

Pushes a signal onto the transmission queue.

The signal will be cloned into an internal buffer to ensure that it is valid for the entire transmission. These buffers will be reused for future transmissions after the current transmission is done.

§Blocking behavior

If the queue is full (i.e. all encoders are busy), this function will behave differently depending on whether TransmitConfig::queue_non_blocking is set or not:

  • If queue_non_blocking is false, it will block until one encoder is available.
  • If queue_non_blocking is true, it will return an error with code ESP_ERR_TIMEOUT. There will be no state change, so the function can be called again immediately.

If this queue has more encoders available than the channel queue size and queue_non_blocking is set, it will copy the signal into the internal buffer, but might fail (with a timeout) to start the transmission if the channel queue is full.

§Panics

If the signal is empty.

Trait Implementations§

Source§

impl<'c, 'd, E> Debug for TxQueue<'c, 'd, E>
where E: Debug + Encoder, E::Item: Debug,

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'c, 'd, E: Encoder> Drop for TxQueue<'c, 'd, E>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'c, 'd, E> Freeze for TxQueue<'c, 'd, E>

§

impl<'c, 'd, E> !RefUnwindSafe for TxQueue<'c, 'd, E>

§

impl<'c, 'd, E> Send for TxQueue<'c, 'd, E>
where <E as Encoder>::Item: Send, E: Send,

§

impl<'c, 'd, E> Sync for TxQueue<'c, 'd, E>
where <E as Encoder>::Item: Sync, E: Sync,

§

impl<'c, 'd, E> Unpin for TxQueue<'c, 'd, E>
where <E as Encoder>::Item: Unpin,

§

impl<'c, 'd, E> UnsafeUnpin for TxQueue<'c, 'd, E>

§

impl<'c, 'd, E> !UnwindSafe for TxQueue<'c, 'd, E>

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

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.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.