MockDevice

Struct MockDevice 

Source
pub struct MockDevice { /* private fields */ }
Available on crate feature mock only.
Expand description

Represents a mock SSP device used for integration tests.

The device can be configured to respond with a default message, e.g. for polling.

Messages generated by the device are sent encoded as SSP formatted message over a serial connection.

Implementations§

Source§

impl MockDevice

Source

pub fn new( path: &str, msg_type: MessageType, response_status: ResponseStatus, ) -> Result<Self>

Creates a new MockDevice.

§Parameters
  • path: file path to the serial device, e.g. /dev/ttyUSB0
  • msg_type: SSP MessageType for default replies
  • response_status: default SSP ResponseStatus for default replies
Source

pub fn serial_path(&self) -> &str

Gets a reference to the file path to the serial device.

Source

pub const fn msg_type(&self) -> MessageType

Gets the default MessageType.

Source

pub fn set_msg_type(&mut self, msg_type: MessageType)

Sets the default MessageType.

Source

pub const fn response_status(&self) -> ResponseStatus

Gets the default ResponseStatus.

Source

pub fn set_response_status(&mut self, response_status: ResponseStatus)

Sets the default ResponseStatus.

Source

pub fn default_response(msg_type: MessageType) -> Option<Box<dyn ResponseOps>>

Gets a default response message based on the MessageType.

Source

pub fn response_data_len(msg_type: MessageType) -> usize

Get the response data length.

Source

pub fn send_default_response(&mut self) -> Result<()>

Sends a default response message over the serial connection.

Source

pub fn serve(&mut self, stop: Arc<AtomicBool>) -> Result<()>

Starts a device server loop

The loop will continue serving configured responses to received message until the stop flag is set to true.

§Parameters
  • stop: atomic flag for stopping the device server loop.

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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