Skip to main content

UnifiedChannel

Struct UnifiedChannel 

Source
pub struct UnifiedChannel<T> { /* private fields */ }
Expand description

Unified channel that adapts to different usage patterns

Implementations§

Source§

impl<T> UnifiedChannel<T>

Source

pub fn new(config: ChannelConfig) -> Result<UnifiedChannel<T>, ChannelError>

Create a new unified channel with given configuration

Source

pub fn with_capacity(capacity: usize) -> Result<UnifiedChannel<T>, ChannelError>

Create with default configuration

Source

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.

Source

pub fn try_send(&self, message: T) -> Result<(), (T, ChannelError)>

Try to send without blocking, returning the message back on failure.

Source

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.

Source

pub fn send_batch(&self, messages: Vec<T>) -> Result<usize, ChannelError>

Send multiple messages in batch (if batching enabled)

Source

pub fn recv_batch(&self, max_count: usize) -> Vec<T>

Receive multiple messages in batch

Source

pub fn close(&self)

Close the channel

Source

pub fn is_closed(&self) -> bool

Check if channel is closed

Source

pub fn len(&self) -> usize

Get current buffer length

Source

pub fn is_empty(&self) -> bool

Check if buffer is empty

Source

pub fn capacity(&self) -> usize

Get buffer capacity

Source

pub fn stats(&self) -> ChannelStatistics

Get channel statistics for monitoring

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.