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§

source

type Transport: Transport

The transport that this transmitter works with

source

type Driver

The driver type that this transmitter uses to send frames

source

type Error: Debug + From<OutOfMemoryError>

An error type

This type must have an out-of-memory variant that can hold an OutOfMemoryError.

Required Methods§

source

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.

source

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 sent
  • Err(nb::Error::WouldBlock): At least one frame could not be sent yet
  • Err(nb::Error::Other(e)): Some other error occurred
source

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.

Implementors§