pub trait SmartDevice {
const UPDATE_INTERVAL: Duration = _;
// Required methods
fn port_number(&self) -> u8;
fn device_type(&self) -> SmartDeviceType;
// Provided methods
fn is_connected(&self) -> bool { ... }
fn timestamp(&self) -> Result<SmartDeviceTimestamp, PortError> { ... }
fn validate_port(&self) -> Result<(), PortError> { ... }
}
Expand description
Defines common functionality shared by all Smart Port devices.
Provided Associated Constants§
Sourceconst UPDATE_INTERVAL: Duration = _
const UPDATE_INTERVAL: Duration = _
The interval at which the V5 brain reads packets from Smart devices.
Required Methods§
Sourcefn port_number(&self) -> u8
fn port_number(&self) -> u8
Sourcefn device_type(&self) -> SmartDeviceType
fn device_type(&self) -> SmartDeviceType
Returns the variant of SmartDeviceType
that this device is associated with.
§Examples
let sensor = InertialSensor::new(peripherals.port_1)?;
assert_eq!(sensor.device_type(), SmartDeviceType::Imu);
Provided Methods§
Sourcefn is_connected(&self) -> bool
fn is_connected(&self) -> bool
Sourcefn timestamp(&self) -> Result<SmartDeviceTimestamp, PortError>
fn timestamp(&self) -> Result<SmartDeviceTimestamp, PortError>
Returns the timestamp recorded by this device’s internal clock.
§Errors
Currently, this function never returns an error. This behavior should be considered unstable.
Sourcefn validate_port(&self) -> Result<(), PortError>
fn validate_port(&self) -> Result<(), PortError>
Verify that the device type is currently plugged into this port, returning an appropriate
PortError
if not available.
§Errors
Returns a PortError
if there is not a physical device of type SmartDevice::device_type
in this SmartDevice
’s port.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.