pub trait Device {
// Required methods
fn id(&self) -> &str;
async fn connect(&mut self) -> Result<()>;
async fn disconnect(&mut self) -> Result<()>;
}Expand description
A connectable physical or virtual device.
Implementors manage the lifecycle of an underlying resource such as a serial port, a network socket, or a vehicle link.
Required Methods§
Sourcefn id(&self) -> &str
fn id(&self) -> &str
Returns the stable identifier for this device.
The identifier is expected to remain constant for the lifetime of the device, for example a serial number, MAC address, or vehicle URI.
§Returns
A string slice borrowing the device’s identifier.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".