Struct omnisensor::i2c::I2CDeviceParams
source · [−]pub struct I2CDeviceParams {
pub bus: u16,
pub address: u16,
pub devtype: I2CDeviceType,
}
Expand description
The information needed to instantiate an I2C device.
Fields
bus: u16
I2C bus number.
address: u16
I2C address.
devtype: I2CDeviceType
Device type.
Implementations
sourceimpl I2CDeviceParams
impl I2CDeviceParams
sourcepub fn from_dbus(
cfg: &PropMap,
devtype: I2CDeviceType
) -> Result<Self, Box<dyn Error>>
pub fn from_dbus(
cfg: &PropMap,
devtype: I2CDeviceType
) -> Result<Self, Box<dyn Error>>
Create an I2CDeviceParams
from a set of dbus properties and a type string.
sourcepub fn sysfs_name(&self) -> String
pub fn sysfs_name(&self) -> String
Return the device name as employed in sysfs, e.g. "2-004c"
.
sourcepub fn sysfs_device_dir(&self) -> PathBuf
pub fn sysfs_device_dir(&self) -> PathBuf
Return the absolute path of the sysfs directory representing the device.
sourcepub fn sysfs_bus_dir(&self) -> PathBuf
pub fn sysfs_bus_dir(&self) -> PathBuf
Return the absolute path of the sysfs directory representing the bus via which the device is attached.
sourcepub fn device_present(&self) -> bool
pub fn device_present(&self) -> bool
Test if the device is currently present, i.e. has had a driver successfully bound to it.
sourcepub fn device_static(&self) -> bool
pub fn device_static(&self) -> bool
Test if the device is static, i.e. instantiated from a device-tree node (as
opposed to a dynamic device instantiate by userspace writing to new_device
).
sourcepub fn instantiate_device(
&self
) -> Result<Option<Arc<I2CDevice>>, Box<dyn Error>>
pub fn instantiate_device(
&self
) -> Result<Option<Arc<I2CDevice>>, Box<dyn Error>>
Attempt to instantiate the device represented by self
, returning:
Ok(None)
if the device is static (we don’t need to manage it).Ok(Some(_))
on success (anI2CDevice
that will remove the device when the last reference to it is dropped).Err(_)
on error.
Trait Implementations
sourceimpl Clone for I2CDeviceParams
impl Clone for I2CDeviceParams
sourcefn clone(&self) -> I2CDeviceParams
fn clone(&self) -> I2CDeviceParams
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresourceimpl Debug for I2CDeviceParams
impl Debug for I2CDeviceParams
sourceimpl Hash for I2CDeviceParams
impl Hash for I2CDeviceParams
sourceimpl PartialEq<I2CDeviceParams> for I2CDeviceParams
impl PartialEq<I2CDeviceParams> for I2CDeviceParams
sourcefn eq(&self, other: &I2CDeviceParams) -> bool
fn eq(&self, other: &I2CDeviceParams) -> bool
impl Eq for I2CDeviceParams
impl StructuralEq for I2CDeviceParams
impl StructuralPartialEq for I2CDeviceParams
Auto Trait Implementations
impl RefUnwindSafe for I2CDeviceParams
impl Send for I2CDeviceParams
impl Sync for I2CDeviceParams
impl Unpin for I2CDeviceParams
impl UnwindSafe for I2CDeviceParams
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more