[−][src]Struct iced_futures::subscription::Subscription
A request to listen to external events.
Besides performing async actions on demand with Command
, most
applications also need to listen to external events passively.
A Subscription
is normally provided to some runtime, like a Command
,
and it will generate events as long as the user keeps requesting it.
For instance, you can use a Subscription
to listen to a WebSocket
connection, keyboard presses, mouse events, time ticks, etc.
This type is normally aliased by runtimes with a specific Event
and/or
Hasher
.
Implementations
impl<H, E, O> Subscription<H, E, O> where
H: Hasher,
[src]
H: Hasher,
pub fn none() -> Self
[src]
Returns an empty Subscription
that will not produce any output.
pub fn from_recipe(recipe: impl Recipe<H, E, Output = O> + 'static) -> Self
[src]
Creates a Subscription
from a Recipe
describing it.
pub fn batch(
subscriptions: impl IntoIterator<Item = Subscription<H, E, O>>
) -> Self
[src]
subscriptions: impl IntoIterator<Item = Subscription<H, E, O>>
) -> Self
Batches all the provided subscriptions and returns the resulting
Subscription
.
pub fn recipes(self) -> Vec<Box<dyn Recipe<H, E, Output = O>>>
[src]
Returns the different recipes of the Subscription
.
pub fn with<T>(self, value: T) -> Subscription<H, E, (T, O)> where
H: 'static,
E: 'static,
O: 'static,
T: Hash + Clone + Send + Sync + 'static,
[src]
H: 'static,
E: 'static,
O: 'static,
T: Hash + Clone + Send + Sync + 'static,
Adds a value to the Subscription
context.
The value will be part of the identity of a Subscription
.
This is necessary if you want to use multiple instances of the same
Subscription
to produce different kinds of messages based on some
external data.
pub fn map<A>(
self,
f: impl Fn(O) -> A + Send + Sync + 'static
) -> Subscription<H, E, A> where
H: 'static,
E: 'static,
O: 'static,
A: 'static,
[src]
self,
f: impl Fn(O) -> A + Send + Sync + 'static
) -> Subscription<H, E, A> where
H: 'static,
E: 'static,
O: 'static,
A: 'static,
Transforms the Subscription
output with the given function.
Trait Implementations
impl<I, O, H> Debug for Subscription<I, O, H>
[src]
Auto Trait Implementations
impl<Hasher, Event, Output> !RefUnwindSafe for Subscription<Hasher, Event, Output>
impl<Hasher, Event, Output> !Send for Subscription<Hasher, Event, Output>
impl<Hasher, Event, Output> !Sync for Subscription<Hasher, Event, Output>
impl<Hasher, Event, Output> Unpin for Subscription<Hasher, Event, Output>
impl<Hasher, Event, Output> !UnwindSafe for Subscription<Hasher, Event, Output>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,