Struct embassy_sync::pubsub::subscriber::Sub
source · pub struct Sub<'a, PSB: PubSubBehavior<T> + ?Sized, T: Clone> { /* private fields */ }
Expand description
A subscriber to a channel
Implementations§
source§impl<'a, PSB: PubSubBehavior<T> + ?Sized, T: Clone> Sub<'a, PSB, T>
impl<'a, PSB: PubSubBehavior<T> + ?Sized, T: Clone> Sub<'a, PSB, T>
sourcepub fn next_message<'s>(&'s mut self) -> SubscriberWaitFuture<'s, 'a, PSB, T> ⓘ
pub fn next_message<'s>(&'s mut self) -> SubscriberWaitFuture<'s, 'a, PSB, T> ⓘ
Wait for a published message
sourcepub async fn next_message_pure(&mut self) -> T
pub async fn next_message_pure(&mut self) -> T
Wait for a published message (ignoring lag results)
sourcepub fn try_next_message(&mut self) -> Option<WaitResult<T>>
pub fn try_next_message(&mut self) -> Option<WaitResult<T>>
Try to see if there’s a published message we haven’t received yet.
This function does not peek. The message is received if there is one.
sourcepub fn try_next_message_pure(&mut self) -> Option<T>
pub fn try_next_message_pure(&mut self) -> Option<T>
Try to see if there’s a published message we haven’t received yet (ignoring lag results).
This function does not peek. The message is received if there is one.
sourcepub fn available(&self) -> u64
pub fn available(&self) -> u64
The amount of messages this subscriber hasn’t received yet. This is like Self::len but specifically for this subscriber.
sourcepub fn free_capacity(&self) -> usize
pub fn free_capacity(&self) -> usize
Returns the free capacity of the channel.
This is equivalent to capacity() - len()
sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of elements currently in the channel. See Self::available for how many messages are available for this subscriber.
Trait Implementations§
source§impl<'a, PSB: PubSubBehavior<T> + ?Sized, T: Clone> Drop for Sub<'a, PSB, T>
impl<'a, PSB: PubSubBehavior<T> + ?Sized, T: Clone> Drop for Sub<'a, PSB, T>
source§impl<'a, PSB: PubSubBehavior<T> + ?Sized, T: Clone> Stream for Sub<'a, PSB, T>
impl<'a, PSB: PubSubBehavior<T> + ?Sized, T: Clone> Stream for Sub<'a, PSB, T>
Warning: The stream implementation ignores lag results and returns all messages. This might miss some messages without you knowing it.
impl<'a, PSB: PubSubBehavior<T> + ?Sized, T: Clone> Unpin for Sub<'a, PSB, T>
Auto Trait Implementations§
impl<'a, PSB, T> Freeze for Sub<'a, PSB, T>where
PSB: ?Sized,
impl<'a, PSB, T> RefUnwindSafe for Sub<'a, PSB, T>where
PSB: RefUnwindSafe + ?Sized,
T: RefUnwindSafe,
impl<'a, PSB, T> Send for Sub<'a, PSB, T>where
PSB: Sync + ?Sized,
T: Send,
impl<'a, PSB, T> Sync for Sub<'a, PSB, T>where
PSB: Sync + ?Sized,
T: Sync,
impl<'a, PSB, T> UnwindSafe for Sub<'a, PSB, T>where
PSB: RefUnwindSafe + ?Sized,
T: UnwindSafe,
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§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
§impl<T, U> Into<U> for Twhere
U: From<T>,
impl<T, U> Into<U> for Twhere
U: From<T>,
source§impl<T> StreamExt for Twhere
T: Stream + ?Sized,
impl<T> StreamExt for Twhere
T: Stream + ?Sized,
source§fn next(&mut self) -> Next<'_, Self>where
Self: Unpin,
fn next(&mut self) -> Next<'_, Self>where
Self: Unpin,
source§fn into_future(self) -> StreamFuture<Self>where
Self: Sized + Unpin,
fn into_future(self) -> StreamFuture<Self>where
Self: Sized + Unpin,
(next_item, tail_of_stream)
.
If the stream terminates, then the next item is [None
]. Read moresource§fn map<T, F>(self, f: F) -> Map<Self, F>where
F: FnMut(Self::Item) -> T,
Self: Sized,
fn map<T, F>(self, f: F) -> Map<Self, F>where
F: FnMut(Self::Item) -> T,
Self: Sized,
source§fn enumerate(self) -> Enumerate<Self>where
Self: Sized,
fn enumerate(self) -> Enumerate<Self>where
Self: Sized,
source§fn filter<Fut, F>(self, f: F) -> Filter<Self, Fut, F>where
F: FnMut(&Self::Item) -> Fut,
Fut: Future<Output = bool>,
Self: Sized,
fn filter<Fut, F>(self, f: F) -> Filter<Self, Fut, F>where
F: FnMut(&Self::Item) -> Fut,
Fut: Future<Output = bool>,
Self: Sized,
source§fn filter_map<Fut, T, F>(self, f: F) -> FilterMap<Self, Fut, F>where
F: FnMut(Self::Item) -> Fut,
Fut: Future<Output = Option<T>>,
Self: Sized,
fn filter_map<Fut, T, F>(self, f: F) -> FilterMap<Self, Fut, F>where
F: FnMut(Self::Item) -> Fut,
Fut: Future<Output = Option<T>>,
Self: Sized,
source§fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F>where
F: FnMut(Self::Item) -> Fut,
Fut: Future,
Self: Sized,
fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F>where
F: FnMut(Self::Item) -> Fut,
Fut: Future,
Self: Sized,
source§fn collect<C>(self) -> Collect<Self, C>where
C: Default + Extend<Self::Item>,
Self: Sized,
fn collect<C>(self) -> Collect<Self, C>where
C: Default + Extend<Self::Item>,
Self: Sized,
source§fn unzip<A, B, FromA, FromB>(self) -> Unzip<Self, FromA, FromB>where
FromA: Default + Extend<A>,
FromB: Default + Extend<B>,
Self: Sized + Stream<Item = (A, B)>,
fn unzip<A, B, FromA, FromB>(self) -> Unzip<Self, FromA, FromB>where
FromA: Default + Extend<A>,
FromB: Default + Extend<B>,
Self: Sized + Stream<Item = (A, B)>,
source§fn concat(self) -> Concat<Self>
fn concat(self) -> Concat<Self>
source§fn count(self) -> Count<Self>where
Self: Sized,
fn count(self) -> Count<Self>where
Self: Sized,
source§fn fold<T, Fut, F>(self, init: T, f: F) -> Fold<Self, Fut, T, F>where
F: FnMut(T, Self::Item) -> Fut,
Fut: Future<Output = T>,
Self: Sized,
fn fold<T, Fut, F>(self, init: T, f: F) -> Fold<Self, Fut, T, F>where
F: FnMut(T, Self::Item) -> Fut,
Fut: Future<Output = T>,
Self: Sized,
source§fn any<Fut, F>(self, f: F) -> Any<Self, Fut, F>where
F: FnMut(Self::Item) -> Fut,
Fut: Future<Output = bool>,
Self: Sized,
fn any<Fut, F>(self, f: F) -> Any<Self, Fut, F>where
F: FnMut(Self::Item) -> Fut,
Fut: Future<Output = bool>,
Self: Sized,
true
if any element in stream satisfied a predicate. Read moresource§fn all<Fut, F>(self, f: F) -> All<Self, Fut, F>where
F: FnMut(Self::Item) -> Fut,
Fut: Future<Output = bool>,
Self: Sized,
fn all<Fut, F>(self, f: F) -> All<Self, Fut, F>where
F: FnMut(Self::Item) -> Fut,
Fut: Future<Output = bool>,
Self: Sized,
true
if all element in stream satisfied a predicate. Read moresource§fn flatten(self) -> Flatten<Self>
fn flatten(self) -> Flatten<Self>
source§fn scan<S, B, Fut, F>(self, initial_state: S, f: F) -> Scan<Self, S, Fut, F>where
F: FnMut(&mut S, Self::Item) -> Fut,
Fut: Future<Output = Option<B>>,
Self: Sized,
fn scan<S, B, Fut, F>(self, initial_state: S, f: F) -> Scan<Self, S, Fut, F>where
F: FnMut(&mut S, Self::Item) -> Fut,
Fut: Future<Output = Option<B>>,
Self: Sized,
StreamExt::fold
that holds internal state
and produces a new stream. Read moresource§fn skip_while<Fut, F>(self, f: F) -> SkipWhile<Self, Fut, F>where
F: FnMut(&Self::Item) -> Fut,
Fut: Future<Output = bool>,
Self: Sized,
fn skip_while<Fut, F>(self, f: F) -> SkipWhile<Self, Fut, F>where
F: FnMut(&Self::Item) -> Fut,
Fut: Future<Output = bool>,
Self: Sized,
true
. Read moresource§fn take_while<Fut, F>(self, f: F) -> TakeWhile<Self, Fut, F>where
F: FnMut(&Self::Item) -> Fut,
Fut: Future<Output = bool>,
Self: Sized,
fn take_while<Fut, F>(self, f: F) -> TakeWhile<Self, Fut, F>where
F: FnMut(&Self::Item) -> Fut,
Fut: Future<Output = bool>,
Self: Sized,
true
. Read moresource§fn take_until<Fut>(self, fut: Fut) -> TakeUntil<Self, Fut>where
Fut: Future,
Self: Sized,
fn take_until<Fut>(self, fut: Fut) -> TakeUntil<Self, Fut>where
Fut: Future,
Self: Sized,
source§fn for_each<Fut, F>(self, f: F) -> ForEach<Self, Fut, F>where
F: FnMut(Self::Item) -> Fut,
Fut: Future<Output = ()>,
Self: Sized,
fn for_each<Fut, F>(self, f: F) -> ForEach<Self, Fut, F>where
F: FnMut(Self::Item) -> Fut,
Fut: Future<Output = ()>,
Self: Sized,
source§fn take(self, n: usize) -> Take<Self>where
Self: Sized,
fn take(self, n: usize) -> Take<Self>where
Self: Sized,
n
items of the underlying stream. Read moresource§fn skip(self, n: usize) -> Skip<Self>where
Self: Sized,
fn skip(self, n: usize) -> Skip<Self>where
Self: Sized,
n
items of the underlying stream. Read moresource§fn zip<St>(self, other: St) -> Zip<Self, St>where
St: Stream,
Self: Sized,
fn zip<St>(self, other: St) -> Zip<Self, St>where
St: Stream,
Self: Sized,
source§fn peekable(self) -> Peekable<Self>where
Self: Sized,
fn peekable(self) -> Peekable<Self>where
Self: Sized,
peek
method. Read moresource§fn inspect<F>(self, f: F) -> Inspect<Self, F>where
F: FnMut(&Self::Item),
Self: Sized,
fn inspect<F>(self, f: F) -> Inspect<Self, F>where
F: FnMut(&Self::Item),
Self: Sized,
source§fn left_stream<B>(self) -> Either<Self, B>
fn left_stream<B>(self) -> Either<Self, B>
source§fn right_stream<B>(self) -> Either<B, Self>
fn right_stream<B>(self) -> Either<B, Self>
source§fn poll_next_unpin(&mut self, cx: &mut Context<'_>) -> Poll<Option<Self::Item>>where
Self: Unpin,
fn poll_next_unpin(&mut self, cx: &mut Context<'_>) -> Poll<Option<Self::Item>>where
Self: Unpin,
Stream::poll_next
on [Unpin
]
stream types.source§fn select_next_some(&mut self) -> SelectNextSome<'_, Self>where
Self: Unpin + FusedStream,
fn select_next_some(&mut self) -> SelectNextSome<'_, Self>where
Self: Unpin + FusedStream,
Future
] that resolves when the next item in this stream is
ready. Read more§impl<T, U> TryFrom<U> for Twhere
U: Into<T>,
impl<T, U> TryFrom<U> for Twhere
U: Into<T>,
§impl<T, U> TryInto<U> for Twhere
U: TryFrom<T>,
impl<T, U> TryInto<U> for Twhere
U: TryFrom<T>,
source§impl<S> TryStreamExt for Swhere
S: TryStream + ?Sized,
impl<S> TryStreamExt for Swhere
S: TryStream + ?Sized,
source§fn err_into<E>(self) -> ErrInto<Self, E>where
Self: Sized,
Self::Error: Into<E>,
fn err_into<E>(self) -> ErrInto<Self, E>where
Self: Sized,
Self::Error: Into<E>,
source§fn map_ok<T, F>(self, f: F) -> MapOk<Self, F>where
Self: Sized,
F: FnMut(Self::Ok) -> T,
fn map_ok<T, F>(self, f: F) -> MapOk<Self, F>where
Self: Sized,
F: FnMut(Self::Ok) -> T,
source§fn map_err<E, F>(self, f: F) -> MapErr<Self, F>where
Self: Sized,
F: FnMut(Self::Error) -> E,
fn map_err<E, F>(self, f: F) -> MapErr<Self, F>where
Self: Sized,
F: FnMut(Self::Error) -> E,
source§fn and_then<Fut, F>(self, f: F) -> AndThen<Self, Fut, F>
fn and_then<Fut, F>(self, f: F) -> AndThen<Self, Fut, F>
f
. Read moresource§fn or_else<Fut, F>(self, f: F) -> OrElse<Self, Fut, F>
fn or_else<Fut, F>(self, f: F) -> OrElse<Self, Fut, F>
f
. Read moresource§fn inspect_ok<F>(self, f: F) -> InspectOk<Self, F>where
F: FnMut(&Self::Ok),
Self: Sized,
fn inspect_ok<F>(self, f: F) -> InspectOk<Self, F>where
F: FnMut(&Self::Ok),
Self: Sized,
source§fn inspect_err<F>(self, f: F) -> InspectErr<Self, F>where
F: FnMut(&Self::Error),
Self: Sized,
fn inspect_err<F>(self, f: F) -> InspectErr<Self, F>where
F: FnMut(&Self::Error),
Self: Sized,
source§fn into_stream(self) -> IntoStream<Self>where
Self: Sized,
fn into_stream(self) -> IntoStream<Self>where
Self: Sized,
source§fn try_next(&mut self) -> TryNext<'_, Self>where
Self: Unpin,
fn try_next(&mut self) -> TryNext<'_, Self>where
Self: Unpin,
source§fn try_for_each<Fut, F>(self, f: F) -> TryForEach<Self, Fut, F>
fn try_for_each<Fut, F>(self, f: F) -> TryForEach<Self, Fut, F>
source§fn try_skip_while<Fut, F>(self, f: F) -> TrySkipWhile<Self, Fut, F>
fn try_skip_while<Fut, F>(self, f: F) -> TrySkipWhile<Self, Fut, F>
true
. Read moresource§fn try_take_while<Fut, F>(self, f: F) -> TryTakeWhile<Self, Fut, F>
fn try_take_while<Fut, F>(self, f: F) -> TryTakeWhile<Self, Fut, F>
true
. Read moresource§fn try_collect<C>(self) -> TryCollect<Self, C>where
C: Default + Extend<Self::Ok>,
Self: Sized,
fn try_collect<C>(self) -> TryCollect<Self, C>where
C: Default + Extend<Self::Ok>,
Self: Sized,
source§fn try_filter<Fut, F>(self, f: F) -> TryFilter<Self, Fut, F>where
Fut: Future<Output = bool>,
F: FnMut(&Self::Ok) -> Fut,
Self: Sized,
fn try_filter<Fut, F>(self, f: F) -> TryFilter<Self, Fut, F>where
Fut: Future<Output = bool>,
F: FnMut(&Self::Ok) -> Fut,
Self: Sized,
source§fn try_filter_map<Fut, F, T>(self, f: F) -> TryFilterMap<Self, Fut, F>
fn try_filter_map<Fut, F, T>(self, f: F) -> TryFilterMap<Self, Fut, F>
source§fn try_flatten(self) -> TryFlatten<Self>
fn try_flatten(self) -> TryFlatten<Self>
source§fn try_fold<T, Fut, F>(self, init: T, f: F) -> TryFold<Self, Fut, T, F>
fn try_fold<T, Fut, F>(self, init: T, f: F) -> TryFold<Self, Fut, T, F>
source§fn try_concat(self) -> TryConcat<Self>
fn try_concat(self) -> TryConcat<Self>
source§fn try_poll_next_unpin(
&mut self,
cx: &mut Context<'_>,
) -> Poll<Option<Result<Self::Ok, Self::Error>>>where
Self: Unpin,
fn try_poll_next_unpin(
&mut self,
cx: &mut Context<'_>,
) -> Poll<Option<Result<Self::Ok, Self::Error>>>where
Self: Unpin,
TryStream::try_poll_next
on [Unpin
]
stream types.source§fn try_all<Fut, F>(self, f: F) -> TryAll<Self, Fut, F>where
Self: Sized,
F: FnMut(Self::Ok) -> Fut,
Fut: Future<Output = bool>,
fn try_all<Fut, F>(self, f: F) -> TryAll<Self, Fut, F>where
Self: Sized,
F: FnMut(Self::Ok) -> Fut,
Fut: Future<Output = bool>,
Err
is encountered or if an Ok
item is found
that does not satisfy the predicate. Read moresource§fn try_any<Fut, F>(self, f: F) -> TryAny<Self, Fut, F>where
Self: Sized,
F: FnMut(Self::Ok) -> Fut,
Fut: Future<Output = bool>,
fn try_any<Fut, F>(self, f: F) -> TryAny<Self, Fut, F>where
Self: Sized,
F: FnMut(Self::Ok) -> Fut,
Fut: Future<Output = bool>,
Err
is encountered or if an Ok
item is found
that satisfies the predicate. Read more