pub trait AsyncLink: Send {
// Required methods
fn open(
&mut self,
geometry: &Geometry,
) -> impl Future<Output = Result<(), LinkError>>;
fn close(&mut self) -> impl Future<Output = Result<(), LinkError>>;
fn alloc_tx_buffer(
&mut self,
) -> impl Future<Output = Result<Vec<TxMessage>, LinkError>>;
fn send(
&mut self,
tx: Vec<TxMessage>,
) -> impl Future<Output = Result<(), LinkError>>;
fn receive(
&mut self,
rx: &mut [RxMessage],
) -> impl Future<Output = Result<(), LinkError>>;
fn is_open(&self) -> bool;
// Provided method
fn ensure_is_open(&self) -> Result<(), LinkError> { ... }
}
Expand description
A trait that provides the interface with the device.
Required Methods§
Sourcefn open(
&mut self,
geometry: &Geometry,
) -> impl Future<Output = Result<(), LinkError>>
fn open( &mut self, geometry: &Geometry, ) -> impl Future<Output = Result<(), LinkError>>
Opens the link.
Sourcefn alloc_tx_buffer(
&mut self,
) -> impl Future<Output = Result<Vec<TxMessage>, LinkError>>
fn alloc_tx_buffer( &mut self, ) -> impl Future<Output = Result<Vec<TxMessage>, LinkError>>
Allocate a sending buffer for the link.
Sourcefn send(
&mut self,
tx: Vec<TxMessage>,
) -> impl Future<Output = Result<(), LinkError>>
fn send( &mut self, tx: Vec<TxMessage>, ) -> impl Future<Output = Result<(), LinkError>>
Sends a message to the device.
Provided Methods§
Sourcefn ensure_is_open(&self) -> Result<(), LinkError>
fn ensure_is_open(&self) -> Result<(), LinkError>
Ensures that the link is open, returning an error if it is not.
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.