pub trait ChannelCommon<ItemType, DerivedItemType>{
// Required methods
fn new<IntoString>(name: IntoString) -> Arc<Self>
where IntoString: Into<String>;
fn flush(&self, timeout: Duration) -> impl Future<Output = u32> + Send;
fn is_channel_open(&self) -> bool;
fn gracefully_end_stream(
&self,
stream_id: u32,
timeout: Duration,
) -> impl Future<Output = bool> + Send;
fn gracefully_end_all_streams(
&self,
timeout: Duration,
) -> impl Future<Output = u32> + Send;
fn cancel_all_streams(&self);
fn running_streams_count(&self) -> u32;
fn pending_items_count(&self) -> u32;
fn buffer_size(&self) -> u32;
}
Expand description
Defines common abstractions on how [Uni]s receives produced events and delivers them to Stream
s.
Implementors should also implement one of ChannelProducer or [UniZeroCopyChannel].
NOTE: all async functions are out of the hot path, so the async_trait
won’t impose performance penalties
Required Methods§
Sourcefn new<IntoString>(name: IntoString) -> Arc<Self>
fn new<IntoString>(name: IntoString) -> Arc<Self>
Creates a new instance of this channel, to be referred to (in logs) as name
Sourcefn flush(&self, timeout: Duration) -> impl Future<Output = u32> + Send
fn flush(&self, timeout: Duration) -> impl Future<Output = u32> + Send
Waits until all pending items are taken from this channel, up until timeout
elapses.
Returns the number of still unconsumed items – which is 0 if it was not interrupted by the timeout
Sourcefn is_channel_open(&self) -> bool
fn is_channel_open(&self) -> bool
Tells weather this channel is still enabled to process elements (true before calling the “end stream” / “cancel stream” functions)
Sourcefn gracefully_end_stream(
&self,
stream_id: u32,
timeout: Duration,
) -> impl Future<Output = bool> + Send
fn gracefully_end_stream( &self, stream_id: u32, timeout: Duration, ) -> impl Future<Output = bool> + Send
Flushes & signals that the given stream_id
should cease its activities when there are no more elements left
to process, waiting for the operation to complete for up to timeout
.
Returns true
if the stream ended within the given timeout
or false
if it is still processing elements.
Sourcefn gracefully_end_all_streams(
&self,
timeout: Duration,
) -> impl Future<Output = u32> + Send
fn gracefully_end_all_streams( &self, timeout: Duration, ) -> impl Future<Output = u32> + Send
Flushes & signals that all streams should cease their activities when there are no more elements left
to process, waiting for the operation to complete for up to timeout
.
Returns the number of un-ended streams – which is 0 if it was not interrupted by the timeout
Sourcefn cancel_all_streams(&self)
fn cancel_all_streams(&self)
Sends a signal to all streams, urging them to cease their operations.
In opposition to [end_all_streams()], this method does not wait for any confirmation,
nor cares if there are remaining elements to be processed.
Sourcefn running_streams_count(&self) -> u32
fn running_streams_count(&self) -> u32
Informs the caller how many active streams are currently managed by this channel IMPLEMENTORS: #[inline(always)]
Sourcefn pending_items_count(&self) -> u32
fn pending_items_count(&self) -> u32
Tells how many events are waiting to be taken out of this channel.
IMPLEMENTORS: #[inline(always)]
Sourcefn buffer_size(&self) -> u32
fn buffer_size(&self) -> u32
Tells how many events may be produced ahead of the consumers.
IMPLEMENTORS: #[inline(always)]
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.