Struct re_smart_channel::receiver::Receiver
source · pub struct Receiver<T: Send> {
pub(crate) rx: Receiver<SmartMessage<T>>,
stats: Arc<SharedStats>,
pub(crate) source: Arc<SmartChannelSource>,
connected: AtomicBool,
}
Fields§
§rx: Receiver<SmartMessage<T>>
§stats: Arc<SharedStats>
§source: Arc<SmartChannelSource>
§connected: AtomicBool
Implementations§
source§impl<T: Send> Receiver<T>
impl<T: Send> Receiver<T>
pub(crate) fn new( rx: Receiver<SmartMessage<T>>, stats: Arc<SharedStats>, source: Arc<SmartChannelSource> ) -> Self
sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
Are we still connected?
Once false, we will never be connected again: the source has run dry.
This is only updated once one of the receive methods fails.
pub fn recv(&self) -> Result<SmartMessage<T>, RecvError>
pub fn try_recv(&self) -> Result<SmartMessage<T>, TryRecvError>
pub fn recv_timeout( &self, timeout: Duration ) -> Result<SmartMessage<T>, RecvTimeoutError>
sourcepub fn recv_with_send_time(&self) -> Result<SmartMessage<T>, RecvError>
pub fn recv_with_send_time(&self) -> Result<SmartMessage<T>, RecvError>
Receives without registering the latency.
This is for use with crate::Sender::send_at
when chaining to another channel
created with Self::chained_channel
.
sourcepub fn source(&self) -> &SmartChannelSource
pub fn source(&self) -> &SmartChannelSource
Where is the data coming from?
sourcepub fn latency_ns(&self) -> u64
pub fn latency_ns(&self) -> u64
Latest known latency from sending a message to receiving it, it nanoseconds.
sourcepub fn latency_sec(&self) -> f32
pub fn latency_sec(&self) -> f32
Latest known latency from sending a message to receiving it, in seconds
sourcepub fn chained_channel(&self) -> (Sender<T>, Self)
pub fn chained_channel(&self) -> (Sender<T>, Self)
Create a new channel that use the same stats as this one.
This means both channels will see the same latency numbers.
Care must be taken to use Self::recv_with_send_time
and crate::Sender::send_at
.
This is a very leaky abstraction, and it would be nice with a refactor.
Auto Trait Implementations§
impl<T> !Freeze for Receiver<T>
impl<T> RefUnwindSafe for Receiver<T>
impl<T> Send for Receiver<T>
impl<T> Sync for Receiver<T>
impl<T> Unpin for Receiver<T>where
T: Unpin,
impl<T> UnwindSafe for Receiver<T>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more