Skip to main content

MockPins

Struct MockPins 

Source
pub struct MockPins { /* private fields */ }
Expand description

Self-contained mock GPIO implementation that records operations and supplies pre-seeded reads.

Call inject_read to pre-seed reads before running code that calls GPIO_READ, and call trace afterwards to inspect the ordered record of all GPIO operations.

Implementations§

Source§

impl MockPins

Source

pub fn inject_read(&mut self, pin: Pin, high: bool)

Pre-seeds a future read(pin) call to return high.

Source

pub fn trace(&self) -> &[i32]

Returns the ordered trace of all GPIO operations performed so far.

Trait Implementations§

Source§

impl Default for MockPins

Source§

fn default() -> MockPins

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

impl Pins for MockPins

Source§

fn as_any(&self) -> &dyn Any

Returns self as &dyn Any to allow downcasting to a concrete type.
Source§

fn as_any_mut(&mut self) -> &mut dyn Any

Returns self as &mut dyn Any to allow downcasting to a concrete type.
Source§

fn setup(&mut self, pin: Pin, mode: PinMode) -> Result<()>

Configures the pin as either input or output (per mode). Read more
Source§

fn clear(&mut self, pin: Pin) -> Result<()>

Resets a given pin to its default state.
Source§

fn clear_all(&mut self) -> Result<()>

Resets all pins to their default state.
Source§

fn read(&mut self, pin: Pin) -> Result<bool>

Reads the value of the given pin, which must have been previously setup as an input pin.
Source§

fn write(&mut self, pin: Pin, v: bool) -> Result<()>

Writes v to the given pin, which must have been previously setup as an output pin.

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V