pub struct DeviceStream { /* private fields */ }Expand description
A connected device stream for bidirectional communication.
Implementations§
Source§impl DeviceStream
impl DeviceStream
pub fn connect( addr: SocketAddr, bus_id: u32, dev_id: &str, password: Option<&str>, ) -> Result<Self, ViiperError>
Sourcepub fn send<T: DeviceInput>(&mut self, input: &T) -> Result<(), ViiperError>
pub fn send<T: DeviceInput>(&mut self, input: &T) -> Result<(), ViiperError>
Send a device input to the device.
Sourcepub fn on_output<F>(&mut self, callback: F) -> Result<(), ViiperError>
pub fn on_output<F>(&mut self, callback: F) -> Result<(), ViiperError>
Register a callback to receive device output asynchronously. The callback receives a BufRead reader and must read the exact number of bytes expected. The callback will be invoked repeatedly on a background thread until it returns an error. Only one callback can be registered at a time.
pub fn on_disconnect<F>(&mut self, callback: F) -> Result<(), ViiperError>
Sourcepub fn send_raw(&mut self, data: &[u8]) -> Result<(), ViiperError>
pub fn send_raw(&mut self, data: &[u8]) -> Result<(), ViiperError>
Send raw bytes to the device.
Sourcepub fn read_raw(&mut self, buf: &mut [u8]) -> Result<usize, ViiperError>
pub fn read_raw(&mut self, buf: &mut [u8]) -> Result<usize, ViiperError>
Read raw bytes from the device.
Sourcepub fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), ViiperError>
pub fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), ViiperError>
Read exact number of bytes from the device.
Trait Implementations§
Source§impl Drop for DeviceStream
impl Drop for DeviceStream
Auto Trait Implementations§
impl Freeze for DeviceStream
impl !RefUnwindSafe for DeviceStream
impl Send for DeviceStream
impl !Sync for DeviceStream
impl Unpin for DeviceStream
impl UnsafeUnpin for DeviceStream
impl !UnwindSafe for DeviceStream
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