Skip to main content

ChannelBinder

Trait ChannelBinder 

Source
pub trait ChannelBinder: Send + Sync {
    // Required methods
    fn create_tx(
        &self,
        initial_credit: u32,
    ) -> (ChannelId, Arc<dyn ChannelSink>);
    fn create_rx(
        &self,
        initial_credit: u32,
    ) -> (ChannelId, BoundChannelReceiver);
    fn bind_tx(
        &self,
        channel_id: ChannelId,
        initial_credit: u32,
    ) -> Arc<dyn ChannelSink>;
    fn register_rx(
        &self,
        channel_id: ChannelId,
        initial_credit: u32,
    ) -> BoundChannelReceiver;

    // Provided method
    fn channel_liveness(&self) -> Option<ChannelLivenessHandle> { ... }
}
Expand description

Trait for channel operations, implemented by the session driver.

This abstraction lets the binding functions and macro-generated code bind channels without depending on concrete driver types.

Required Methods§

Source

fn create_tx(&self, initial_credit: u32) -> (ChannelId, Arc<dyn ChannelSink>)

Allocate a channel ID and create a sink for sending items.

initial_credit is the const generic N from Tx<T, N> or Rx<T, N>.

Source

fn create_rx(&self, initial_credit: u32) -> (ChannelId, BoundChannelReceiver)

Allocate a channel ID, register it for routing, and return a receiver.

Source

fn bind_tx( &self, channel_id: ChannelId, initial_credit: u32, ) -> Arc<dyn ChannelSink>

Create a sink for a known channel ID (callee side).

The channel ID comes from Request.channels. initial_credit is the const generic N from Tx<T, N>.

Source

fn register_rx( &self, channel_id: ChannelId, initial_credit: u32, ) -> BoundChannelReceiver

Register an inbound channel by ID and return the receiver (callee side).

The channel ID comes from Request.channels.

Provided Methods§

Source

fn channel_liveness(&self) -> Option<ChannelLivenessHandle>

Optional opaque handle that keeps the underlying session/connection alive for the lifetime of any bound channel handle.

Implementors§