Skip to main content

MockLoraRadio

Struct MockLoraRadio 

Source
pub struct MockLoraRadio {
    pub inbox: Vec<Vec<u8, MOCK_FRAME_CAP>, MOCK_QUEUE_CAP>,
    pub outbox: Vec<Vec<u8, MOCK_FRAME_CAP>, MOCK_QUEUE_CAP>,
}
Expand description

In-memory LoRa radio. Implements both send and recv against a pair of FIFO buffers. Tests typically pre-load inbox and inspect outbox after the unit under test runs.

Fields§

§inbox: Vec<Vec<u8, MOCK_FRAME_CAP>, MOCK_QUEUE_CAP>§outbox: Vec<Vec<u8, MOCK_FRAME_CAP>, MOCK_QUEUE_CAP>

Implementations§

Source§

impl MockLoraRadio

Source

pub fn new() -> Self

Source

pub fn enqueue_inbox(&mut self, frame: &[u8]) -> Result<(), MockError>

Push a frame into the inbox so a subsequent recv returns it.

Trait Implementations§

Source§

impl Debug for MockLoraRadio

Source§

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

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

impl Default for MockLoraRadio

Source§

fn default() -> Self

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

impl LoraRadio for MockLoraRadio

Source§

type Error = MockError

Source§

fn send(&mut self, payload: &[u8]) -> Result<(), Self::Error>

Transmit payload as a single LoRa frame. Blocks until the frame has been handed to the radio’s TX queue.
Source§

fn recv(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>

Read the next received frame into buf and return its size in bytes. Should block until at least one frame is available, or return an Error on timeout per implementation policy.

Auto Trait Implementations§

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.