pub struct ReceiverU16<T, const N: usize> { /* private fields */ }Available on crate feature
queue only.Expand description
Receives values from the associated Sender.
Implementations§
Source§impl<T, const N: usize> ReceiverU16<T, N>
impl<T, const N: usize> ReceiverU16<T, N>
Sourcepub async fn recv(&self) -> T
pub async fn recv(&self) -> T
Receives the next value for this receiver.
use std::ops::Add;
use tokio::time::{Duration, Instant};
use prosa::event::queue::{QueueChecker, timed};
#[tokio::main]
async fn main() {
let (mut tx, rx) = timed::channel_spmc_u16::<i32, 4096>();
assert!(tx.is_empty());
assert_eq!(Ok(()), tx.try_send(0, Instant::now().add(Duration::from_millis(200))));
// If the element hasn't been consumed and it's not expired, you should get it
assert_eq!(0, rx.recv().await);
}Sourcepub fn try_recv(&self) -> Result<Option<T>, QueueError<T>>
pub fn try_recv(&self) -> Result<Option<T>, QueueError<T>>
Tries to receive the next value for this receiver.
If the queue is empty, it return Err(QueueError::Empty)
If the element can’t be pulled because of synchronicity, it return Ok(None)
use std::ops::Add;
use tokio::time::{Duration, Instant};
use prosa::event::queue::{QueueChecker, timed};
let (mut tx, rx) = timed::channel_spmc_u16::<i32, 4096>();
assert!(tx.is_empty());
assert_eq!(Ok(()), tx.try_send(0, Instant::now().add(Duration::from_millis(200))));
// The try_recv method return an Ok
// But can return either `Ok(Some(0))` or `Ok(None)` depending on internal atomic
assert!(rx.try_recv().is_ok());Trait Implementations§
Source§impl<T, const N: usize> Clone for ReceiverU16<T, N>
impl<T, const N: usize> Clone for ReceiverU16<T, N>
Source§impl<T, const N: usize> Debug for ReceiverU16<T, N>
impl<T, const N: usize> Debug for ReceiverU16<T, N>
Source§impl<T, const N: usize> QueueChecker<u16> for ReceiverU16<T, N>
impl<T, const N: usize> QueueChecker<u16> for ReceiverU16<T, N>
impl<T, const N: usize> Unpin for ReceiverU16<T, N>
Auto Trait Implementations§
impl<T, const N: usize> Freeze for ReceiverU16<T, N>
impl<T, const N: usize> !RefUnwindSafe for ReceiverU16<T, N>
impl<T, const N: usize> Send for ReceiverU16<T, N>
impl<T, const N: usize> Sync for ReceiverU16<T, N>
impl<T, const N: usize> UnsafeUnpin for ReceiverU16<T, N>
impl<T, const N: usize> !UnwindSafe for ReceiverU16<T, N>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request