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
impl MockDevice
Sourcepub fn new(
path: &str,
msg_type: MessageType,
response_status: ResponseStatus,
) -> Result<Self>
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/ttyUSB0msg_type: SSP MessageType for default repliesresponse_status: default SSP ResponseStatus for default replies
Sourcepub fn serial_path(&self) -> &str
pub fn serial_path(&self) -> &str
Gets a reference to the file path to the serial device.
Sourcepub const fn msg_type(&self) -> MessageType
pub const fn msg_type(&self) -> MessageType
Gets the default MessageType.
Sourcepub fn set_msg_type(&mut self, msg_type: MessageType)
pub fn set_msg_type(&mut self, msg_type: MessageType)
Sets the default MessageType.
Sourcepub const fn response_status(&self) -> ResponseStatus
pub const fn response_status(&self) -> ResponseStatus
Gets the default ResponseStatus.
Sourcepub fn set_response_status(&mut self, response_status: ResponseStatus)
pub fn set_response_status(&mut self, response_status: ResponseStatus)
Sets the default ResponseStatus.
Sourcepub fn default_response(msg_type: MessageType) -> Option<Box<dyn ResponseOps>>
pub fn default_response(msg_type: MessageType) -> Option<Box<dyn ResponseOps>>
Gets a default response message based on the MessageType.
Sourcepub fn response_data_len(msg_type: MessageType) -> usize
pub fn response_data_len(msg_type: MessageType) -> usize
Get the response data length.
Sourcepub fn send_default_response(&mut self) -> Result<()>
pub fn send_default_response(&mut self) -> Result<()>
Sends a default response message over the serial connection.
Auto Trait Implementations§
impl Freeze for MockDevice
impl RefUnwindSafe for MockDevice
impl Send for MockDevice
impl Sync for MockDevice
impl Unpin for MockDevice
impl UnwindSafe for MockDevice
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more