pub struct SenderU16<T, const N: usize> { /* private fields */ }Available on crate feature
queue only.Expand description
Sends values to the associated Receiver.
Implementations§
Source§impl<T, const N: usize> SenderU16<T, N>
impl<T, const N: usize> SenderU16<T, N>
Sourcepub async fn send(
&mut self,
value: T,
timeout: Instant,
) -> Result<(), SendError<T>>
pub async fn send( &mut self, value: T, timeout: Instant, ) -> Result<(), SendError<T>>
Sends a value, waiting until there is capacity.
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.send(0, Instant::now().add(Duration::from_millis(200))).await);
}Sourcepub fn try_send(
&mut self,
value: T,
timeout: Instant,
) -> Result<(), SendError<T>>
pub fn try_send( &mut self, value: T, timeout: Instant, ) -> Result<(), SendError<T>>
Try to send a value, return an Full error if the queue is full
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))));Sourcepub async fn timeout(&mut self) -> Option<T>
pub async fn timeout(&mut self) -> Option<T>
Method to retrieve expired message sent in the queue.
use std::ops::Add;
use tokio::time::{Duration, Instant, sleep};
use prosa::event::queue::timed;
#[tokio::main]
async fn main() {
let (mut tx, _rx) = timed::channel_spmc_u16::<i32, 4096>();
tx.send(1, Instant::now().add(Duration::from_millis(10))).await;
// The data is not consumed during that time
assert_eq!(Some(1), tx.timeout().await);
}Trait Implementations§
Auto Trait Implementations§
impl<T, const N: usize> Freeze for SenderU16<T, N>
impl<T, const N: usize> !RefUnwindSafe for SenderU16<T, N>
impl<T, const N: usize> Send for SenderU16<T, N>
impl<T, const N: usize> Sync for SenderU16<T, N>
impl<T, const N: usize> Unpin for SenderU16<T, N>
impl<T, const N: usize> UnsafeUnpin for SenderU16<T, N>
impl<T, const N: usize> !UnwindSafe for SenderU16<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> 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