Skip to main content

impl_embedded_session_transport

Macro impl_embedded_session_transport 

Source
macro_rules! impl_embedded_session_transport {
    ($reader:ty, $writer:ty, $n:expr) => { ... };
}
Available on crate feature embedded only.
Expand description

Generate a SessionTransport impl for a concrete EmbeddedLeg<$reader, $writer, $n>.

embedded-io-async’s Read::read / Write::write are async-fn-in-trait methods whose returned futures are not Send-bounded. A generic blanket impl<R, W> SessionTransport for EmbeddedLeg<R, W, N> therefore cannot satisfy SessionTransport’s + Send constraint without the unstable return_type_notation feature. By emitting the impl with concrete $reader / $writer types, the compiler sees the HAL’s actual future at the use site and can prove Send directly.

Downstream HAL adapters call this once per (reader, writer, N) triple they expose:

use phantom_protocol::impl_embedded_session_transport;
impl_embedded_session_transport!(MyUartRx, MyUartTx, 1024);