pub struct Device<'c> {
pub client: &'c Client,
/* private fields */
}
Expand description
A Client
wrapper that talks to a specific ADS device.
Fields
client: &'c Client
The underlying Client
.
Implementations
sourceimpl<'c> Device<'c>
impl<'c> Device<'c>
sourcepub fn get_info(&self) -> Result<DeviceInfo>
pub fn get_info(&self) -> Result<DeviceInfo>
Read the device’s name + version.
sourcepub fn read(
&self,
index_group: u32,
index_offset: u32,
data: &mut [u8]
) -> Result<usize>
pub fn read(
&self,
index_group: u32,
index_offset: u32,
data: &mut [u8]
) -> Result<usize>
Read some data at a given index group/offset. Returned data can be shorter than the buffer, the length is the return value.
sourcepub fn read_exact(
&self,
index_group: u32,
index_offset: u32,
data: &mut [u8]
) -> Result<()>
pub fn read_exact(
&self,
index_group: u32,
index_offset: u32,
data: &mut [u8]
) -> Result<()>
Read some data at a given index group/offset, ensuring that the returned data has exactly the size of the passed buffer.
sourcepub fn write(
&self,
index_group: u32,
index_offset: u32,
data: &[u8]
) -> Result<()>
pub fn write(
&self,
index_group: u32,
index_offset: u32,
data: &[u8]
) -> Result<()>
Write some data to a given index group/offset.
sourcepub fn write_read(
&self,
index_group: u32,
index_offset: u32,
write_data: &[u8],
read_data: &mut [u8]
) -> Result<usize>
pub fn write_read(
&self,
index_group: u32,
index_offset: u32,
write_data: &[u8],
read_data: &mut [u8]
) -> Result<usize>
Write some data to a given index group/offset and then read back some reply from there. This is not the same as a write() followed by read(); it is used as a kind of RPC call.
sourcepub fn write_read_exact(
&self,
index_group: u32,
index_offset: u32,
write_data: &[u8],
read_data: &mut [u8]
) -> Result<()>
pub fn write_read_exact(
&self,
index_group: u32,
index_offset: u32,
write_data: &[u8],
read_data: &mut [u8]
) -> Result<()>
Like write_read
, but ensure the returned data length matches the output buffer.
sourcepub fn get_state(&self) -> Result<(AdsState, u16)>
pub fn get_state(&self) -> Result<(AdsState, u16)>
Return the ADS and device state of the device.
sourcepub fn write_control(&self, ads_state: AdsState, dev_state: u16) -> Result<()>
pub fn write_control(&self, ads_state: AdsState, dev_state: u16) -> Result<()>
(Try to) set the ADS and device state of the device.
sourcepub fn add_notification(
&self,
index_group: u32,
index_offset: u32,
attributes: &Attributes
) -> Result<Handle>
pub fn add_notification(
&self,
index_group: u32,
index_offset: u32,
attributes: &Attributes
) -> Result<Handle>
Add a notification handle for some index group/offset.
Notifications are delivered via a MPMC channel whose reading end can be
obtained from get_notification_channel
on the Client
object.
The returned Handle
can be used to check which notification has fired.
If the notification is not deleted explictly using delete_notification
and the Handle
, it is deleted when the Client
object is dropped.
sourcepub fn delete_notification(&self, handle: Handle) -> Result<()>
pub fn delete_notification(&self, handle: Handle) -> Result<()>
Delete a notification with given handle.
Trait Implementations
Auto Trait Implementations
impl<'c> !RefUnwindSafe for Device<'c>
impl<'c> !Send for Device<'c>
impl<'c> !Sync for Device<'c>
impl<'c> Unpin for Device<'c>
impl<'c> !UnwindSafe for Device<'c>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
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
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more