pub struct UnifiedChannel<T> { /* private fields */ }Expand description
Unified channel that adapts to different usage patterns
Implementations§
Source§impl<T> UnifiedChannel<T>
impl<T> UnifiedChannel<T>
Sourcepub fn new(config: ChannelConfig) -> Result<UnifiedChannel<T>, ChannelError>
pub fn new(config: ChannelConfig) -> Result<UnifiedChannel<T>, ChannelError>
Create a new unified channel with given configuration
Sourcepub fn with_capacity(capacity: usize) -> Result<UnifiedChannel<T>, ChannelError>
pub fn with_capacity(capacity: usize) -> Result<UnifiedChannel<T>, ChannelError>
Create with default configuration
Sourcepub fn send(&self, message: T) -> Result<(), ChannelError>
pub fn send(&self, message: T) -> Result<(), ChannelError>
Send a message with automatic overflow handling (non-blocking).
Returns Err(ChannelError::Full) when both the ring buffer and the
overflow pool are full (or pooling is disabled), and Err(Closed) when the
channel is closed. In both error cases the message is consumed (dropped):
the failure is surfaced explicitly, but the value cannot be recovered. A
caller that needs the value back to retry must use Self::try_send, which
returns it in the error. This delegates to try_send (single SSOT for the
send path) rather than duplicating the overflow logic.
Sourcepub fn try_send(&self, message: T) -> Result<(), (T, ChannelError)>
pub fn try_send(&self, message: T) -> Result<(), (T, ChannelError)>
Try to send without blocking, returning the message back on failure.
Sourcepub fn recv(&self) -> Result<T, ChannelError>
pub fn recv(&self) -> Result<T, ChannelError>
Receive a message (non-blocking).
Returns Err(Empty) when no message is currently available and
Err(Closed) once the channel is closed and drained; this channel has
no blocking receive path.
Sourcepub fn send_batch(&self, messages: Vec<T>) -> Result<usize, ChannelError>
pub fn send_batch(&self, messages: Vec<T>) -> Result<usize, ChannelError>
Send multiple messages in batch (if batching enabled)
Sourcepub fn recv_batch(&self, max_count: usize) -> Vec<T>
pub fn recv_batch(&self, max_count: usize) -> Vec<T>
Receive multiple messages in batch
Sourcepub fn stats(&self) -> ChannelStatistics
pub fn stats(&self) -> ChannelStatistics
Get channel statistics for monitoring