#[non_exhaustive]pub struct StatefulListener<St, Assf, Sf, Hauf> {
pub state: St,
pub stream: Assf,
pub stop_token: Sf,
pub hint_allowed_updates: Option<Hauf>,
}Expand description
A listener created from functions.
This type allows to turn a stream of updates (+ some additional functions)
into an UpdateListener.
For an example of usage, see Polling.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.state: StThe state of the listener.
stream: AssfThe function used as AsUpdateStream::as_stream.
Must implement for<'a> FnMut(&'a mut St) -> impl Stream + 'a.
stop_token: SfThe function used as UpdateListener::stop_token.
Must implement FnMut(&mut St) -> StopToken.
hint_allowed_updates: Option<Hauf>The function used as UpdateListener::hint_allowed_updates.
Must implement FnMut(&mut St, &mut dyn Iterator<Item = AllowedUpdate>).
Implementations§
Source§impl<St, Assf, Sf> StatefulListener<St, Assf, Sf, for<'a, 'b> fn(&'a mut St, &'b mut dyn Iterator<Item = AllowedUpdate>)>
impl<St, Assf, Sf> StatefulListener<St, Assf, Sf, for<'a, 'b> fn(&'a mut St, &'b mut dyn Iterator<Item = AllowedUpdate>)>
Source§impl<St, Assf, Sf, Hauf> StatefulListener<St, Assf, Sf, Hauf>
impl<St, Assf, Sf, Hauf> StatefulListener<St, Assf, Sf, Hauf>
Sourcepub fn new_with_hints(
state: St,
stream: Assf,
stop_token: Sf,
hint_allowed_updates: Option<Hauf>,
) -> Self
pub fn new_with_hints( state: St, stream: Assf, stop_token: Sf, hint_allowed_updates: Option<Hauf>, ) -> Self
Creates a new stateful listener from its components.
Trait Implementations§
Source§impl<'a, St, Assf, Sf, Hauf, Strm, E> AsUpdateStream<'a> for StatefulListener<St, Assf, Hauf, Sf>where
(St, Strm): 'a,
Strm: Send + Stream<Item = Result<Update, E>>,
Assf: FnMut(&'a mut St) -> Strm,
impl<'a, St, Assf, Sf, Hauf, Strm, E> AsUpdateStream<'a> for StatefulListener<St, Assf, Hauf, Sf>where
(St, Strm): 'a,
Strm: Send + Stream<Item = Result<Update, E>>,
Assf: FnMut(&'a mut St) -> Strm,
Source§impl<St, Assf, Sf, Hauf, E> UpdateListener for StatefulListener<St, Assf, Sf, Hauf>where
Self: for<'a> AsUpdateStream<'a, StreamErr = E>,
Sf: FnMut(&mut St) -> StopToken,
Hauf: FnMut(&mut St, &mut dyn Iterator<Item = AllowedUpdate>),
impl<St, Assf, Sf, Hauf, E> UpdateListener for StatefulListener<St, Assf, Sf, Hauf>where
Self: for<'a> AsUpdateStream<'a, StreamErr = E>,
Sf: FnMut(&mut St) -> StopToken,
Hauf: FnMut(&mut St, &mut dyn Iterator<Item = AllowedUpdate>),
Source§fn stop_token(&mut self) -> StopToken
fn stop_token(&mut self) -> StopToken
Returns a token which stops this listener. Read more
Source§fn hint_allowed_updates(
&mut self,
hint: &mut dyn Iterator<Item = AllowedUpdate>,
)
fn hint_allowed_updates( &mut self, hint: &mut dyn Iterator<Item = AllowedUpdate>, )
Hint which updates should the listener listen for. Read more
Auto Trait Implementations§
impl<St, Assf, Sf, Hauf> Freeze for StatefulListener<St, Assf, Sf, Hauf>
impl<St, Assf, Sf, Hauf> RefUnwindSafe for StatefulListener<St, Assf, Sf, Hauf>
impl<St, Assf, Sf, Hauf> Send for StatefulListener<St, Assf, Sf, Hauf>
impl<St, Assf, Sf, Hauf> Sync for StatefulListener<St, Assf, Sf, Hauf>
impl<St, Assf, Sf, Hauf> Unpin for StatefulListener<St, Assf, Sf, Hauf>
impl<St, Assf, Sf, Hauf> UnwindSafe for StatefulListener<St, Assf, Sf, Hauf>
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> Erasable for T
impl<T> Erasable for T
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> 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