pub struct ThreadReceiver<T> { /* private fields */ }Expand description
A thread-safe channel receiver for intra-process communication.
This is the receiving half of a ThreadChannel. It can be cloned to create
multiple consumers that receive from the same channel.
Implementations§
Source§impl<T> ThreadReceiver<T>
impl<T> ThreadReceiver<T>
Sourcepub fn recv(&self) -> Result<T>
pub fn recv(&self) -> Result<T>
Receive a message from the channel.
This method blocks until a message is available.
§Errors
Returns IpcError::Closed if the channel has been shutdown or all senders have been dropped.
Sourcepub fn try_recv(&self) -> Result<T>
pub fn try_recv(&self) -> Result<T>
Try to receive a message without blocking.
§Errors
IpcError::Closedif the channel has been shutdown or all senders have been dropped.IpcError::WouldBlockif no message is available.
Sourcepub fn recv_timeout(&self, timeout: Duration) -> Result<T>
pub fn recv_timeout(&self, timeout: Duration) -> Result<T>
Receive a message with a timeout.
§Errors
IpcError::Closedif the channel has been shutdown or all senders have been dropped.IpcError::Timeoutif the timeout expires before a message is available.
Sourcepub fn capacity(&self) -> Option<usize>
pub fn capacity(&self) -> Option<usize>
Get the capacity of the channel (None for unbounded channels).
Sourcepub fn is_shutdown(&self) -> bool
pub fn is_shutdown(&self) -> bool
Check if the channel has been shutdown.
Trait Implementations§
Source§impl<T> Clone for ThreadReceiver<T>
impl<T> Clone for ThreadReceiver<T>
Source§impl<T: Debug> Debug for ThreadReceiver<T>
impl<T: Debug> Debug for ThreadReceiver<T>
Source§impl<T> GracefulChannel for ThreadReceiver<T>
impl<T> GracefulChannel for ThreadReceiver<T>
Source§fn is_shutdown(&self) -> bool
fn is_shutdown(&self) -> bool
Check if the channel has been signaled to shutdown
Auto Trait Implementations§
impl<T> Freeze for ThreadReceiver<T>
impl<T> RefUnwindSafe for ThreadReceiver<T>
impl<T> Send for ThreadReceiver<T>where
T: Send,
impl<T> Sync for ThreadReceiver<T>where
T: Send,
impl<T> Unpin for ThreadReceiver<T>where
T: Unpin,
impl<T> UnwindSafe for ThreadReceiver<T>
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoMetered for T
impl<T> IntoMetered for T
Source§fn metered(self, metrics: Arc<ChannelMetrics>) -> MeteredSender<Self>
fn metered(self, metrics: Arc<ChannelMetrics>) -> MeteredSender<Self>
Wrap this sender with metrics tracking.
Source§impl<T> WithMetrics for T
impl<T> WithMetrics for T
Source§fn with_metrics(self) -> MeteredWrapper<Self>
fn with_metrics(self) -> MeteredWrapper<Self>
Wrap this channel with metrics tracking.