Trait canadensis_core::transport::Transmitter
source · pub trait Transmitter<C>where
C: Clock,{
type Transport: Transport;
type Driver;
type Error: Debug + From<OutOfMemoryError>;
// Required methods
fn push<A>(
&mut self,
transfer: Transfer<A, C::Instant, Self::Transport>,
clock: &mut C,
driver: &mut Self::Driver
) -> Result<(), Self::Error>
where A: AsRef<[u8]>;
fn flush(
&mut self,
clock: &mut C,
driver: &mut Self::Driver
) -> Result<(), Self::Error>;
fn mtu(&self) -> usize;
}
Expand description
A transmitter that can send outgoing transfers
Required Associated Types§
sourcetype Error: Debug + From<OutOfMemoryError>
type Error: Debug + From<OutOfMemoryError>
An error type
This type must have an out-of-memory variant that can hold an OutOfMemoryError
.
Required Methods§
sourcefn push<A>(
&mut self,
transfer: Transfer<A, C::Instant, Self::Transport>,
clock: &mut C,
driver: &mut Self::Driver
) -> Result<(), Self::Error>where
A: AsRef<[u8]>,
fn push<A>( &mut self, transfer: Transfer<A, C::Instant, Self::Transport>, clock: &mut C, driver: &mut Self::Driver ) -> Result<(), Self::Error>where A: AsRef<[u8]>,
Starts the process of sending an outgoing transfer
The transport implementation may block until the entire transfer is sent, or put frames in a queue to be sent separately.
sourcefn flush(
&mut self,
clock: &mut C,
driver: &mut Self::Driver
) -> Result<(), Self::Error>
fn flush( &mut self, clock: &mut C, driver: &mut Self::Driver ) -> Result<(), Self::Error>
Attempts to send all queued outgoing frames
If ths transport’s push
implementation blocks until all frames have been sent,
this function may be empty.
The transport implementation may block until all frames have been sent, or return
Err(nb::Error::WouldBlock)
if not all frames can be sent.
Return values:
Ok(())
: All frames were sentErr(nb::Error::WouldBlock)
: At least one frame could not be sent yetErr(nb::Error::Other(e))
: Some other error occurred
sourcefn mtu(&self) -> usize
fn mtu(&self) -> usize
Returns the maximum transmission unit of this transport, in bytes
A message larger than this will need to be split into multiple frames.
For example, Cyphal/CAN over classic CAN can transfer up to 7 bytes per frame (the eighth byte is used up by the tail byte), so it would return 7.