pub trait SendScdcTransport: Send + Sync {
type Error: Send;
// Required methods
fn read(
&self,
reg: u8,
) -> impl Future<Output = Result<u8, Self::Error>> + Send;
fn write(
&mut self,
reg: u8,
value: u8,
) -> impl Future<Output = Result<(), Self::Error>> + Send;
// Provided method
fn read_block(
&self,
reg: u8,
buf: &mut [u8],
) -> impl Future<Output = Result<(), Self::Error>> + Send { ... }
}Expand description
The transport’s Send twin, re-exported from hdmi-hal-async: bound generic code by it
to spawn work through Scdc<T> on a multi-threaded executor.
ScdcTransport with Send futures, for code that spawns link training on a
multi-threaded executor.
ScdcTransport’s async fns promise nothing about their futures, so code generic over
T: ScdcTransport cannot spawn a future that calls them, however T is bounded. This
trait has the same methods and contract, each returning a future that is Send, and
errors that are Send too: a spawned task returns them. Implementations still write
async fn; the compiler checks that each future is Send.
The transport is Sync as well as Send: read takes &self, and a
future holding &self is only Send when Self is Sync. A transport that keeps
interior state for reads uses a Sync type for it (an atomic or a lock rather than a
Cell).
Every SendScdcTransport is an ScdcTransport, through a blanket implementation, so
it works with everything written against ScdcTransport as well (a read_block
override included); a type implements one of the two (implementing both conflicts with
the blanket implementation). A SendScdcTransport type has both traits’ methods, so
with both traits in scope a method call on it is ambiguous: import only the trait the
code is bounded by, or call SendScdcTransport::read(…).
Required Associated Types§
Required Methods§
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".