pub trait ChannelSpec:
Sealed
+ Sized
+ 'static {
type Sender<T: Debug + Send + 'static>: Sink<T, Error = Self::SendError> + Debug + Unpin + Sized;
type Receiver<T: Debug + Send + 'static>: Stream<Item = T> + Debug + Unpin + Send + Sized;
type SendError: Error;
// Required methods
fn raw_channel<T: Debug + Send + 'static>(
self,
) -> (Self::Sender<T>, Self::Receiver<T>);
fn close_receiver<T: Debug + Send + 'static>(rx: &mut Self::Receiver<T>);
// Provided method
fn new_mq<T>(
self,
runtime: DynTimeProvider,
account: &Account,
) -> Result<(Sender<T, Self>, Receiver<T, Self>)>
where T: HasMemoryCost + Debug + Send + 'static { ... }
}
Expand description
Specification for a communication channel
Implemented for MpscSpec
and MpscUnboundedSpec
.
Required Associated Types§
Sourcetype Sender<T: Debug + Send + 'static>: Sink<T, Error = Self::SendError> + Debug + Unpin + Sized
type Sender<T: Debug + Send + 'static>: Sink<T, Error = Self::SendError> + Debug + Unpin + Sized
The sending [Sink
] for items of type T
.
Required Methods§
Sourcefn raw_channel<T: Debug + Send + 'static>(
self,
) -> (Self::Sender<T>, Self::Receiver<T>)
fn raw_channel<T: Debug + Send + 'static>( self, ) -> (Self::Sender<T>, Self::Receiver<T>)
Create a new raw channel as specified by self
Sourcefn close_receiver<T: Debug + Send + 'static>(rx: &mut Self::Receiver<T>)
fn close_receiver<T: Debug + Send + 'static>(rx: &mut Self::Receiver<T>)
Close the receiver, preventing further sends
This should ensure that only a smallish bounded number of further items can be sent, before errors start being returned.
Provided Methods§
Sourcefn new_mq<T>(
self,
runtime: DynTimeProvider,
account: &Account,
) -> Result<(Sender<T, Self>, Receiver<T, Self>)>
fn new_mq<T>( self, runtime: DynTimeProvider, account: &Account, ) -> Result<(Sender<T, Self>, Receiver<T, Self>)>
Create a new channel, based on the spec self
, that participates in the memory quota
See the module-level docs for an example.
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.