Skip to main content

InMemoryChannel

Struct InMemoryChannel 

Source
pub struct InMemoryChannel { /* private fields */ }
Expand description

In-process CommandChannel backed by unbounded futures MPSC queues. Useful for tests and for wiring multiple registries running inside a single process (e.g. across async tasks or worker threads).

Implementations§

Source§

impl InMemoryChannel

Source

pub fn pair( id_a: impl Into<String>, id_b: impl Into<String>, ) -> (Arc<Self>, Arc<Self>)

Returns two channels wired to each other. A message sent on one arrives on the other’s recv.

Each half carries a label, since the registry uses it as the routing key. The two halves typically use each other’s labels: the parent calls the child channel "child" and vice versa.

Trait Implementations§

Source§

impl CommandChannel for InMemoryChannel

Source§

fn id(&self) -> &str

Stable identifier used by the registry to key routing tables.
Source§

fn start(&self) -> BoxFuture<'_, Result<(), ChannelError>>

Performs any connection/handshake setup. Called once by the registry before the first recv.
Source§

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.
Source§

fn send(&self, msg: Message) -> Result<(), ChannelError>

Fire-and-forget send. Returns immediately without waiting for the peer to receive the message.
Source§

fn recv(&self) -> BoxFuture<'_, Option<Message>>

Awaits the next incoming message. Returns None when the channel has been closed by either side.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.