[][src]Struct iced_futures::subscription::Subscription

pub struct Subscription<Hasher, Event, Output> { /* fields omitted */ }

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]

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]

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]

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]

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]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.