pub trait CommandChannel: Send + Sync {
// Required methods
fn id(&self) -> &str;
fn start(&self) -> BoxFuture<'_, Result<(), ChannelError>>;
fn close(&self) -> BoxFuture<'_, ()>;
fn send(&self, msg: Message) -> Result<(), ChannelError>;
fn recv(&self) -> BoxFuture<'_, Option<Message>>;
}Expand description
Transport carrying Messages between two command registries.
Every method takes &self so the channel can be shared across tasks
as an Arc<dyn CommandChannel>. Implementations provide their own
interior synchronization. The registry drives recv from a single
task, so implementations may assume a single concurrent recv
caller.
The async methods return BoxFuture rather than impl Future so
dyn CommandChannel is object-safe. This is the same shape
#[async_trait] produces internally, written out by hand to avoid
the dependency.
Required Methods§
Sourcefn start(&self) -> BoxFuture<'_, Result<(), ChannelError>>
fn start(&self) -> BoxFuture<'_, Result<(), ChannelError>>
Performs any connection/handshake setup. Called once by the registry before the first recv.
Sourcefn close(&self) -> BoxFuture<'_, ()>
fn close(&self) -> BoxFuture<'_, ()>
Releases any resources and signals the peer that the channel is
going away. After close, send must return Err(Closed) and
recv must return None.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".