Struct iced_futures::subscription::Subscription
source · pub struct Subscription<Message> { /* private fields */ }
Expand description
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.
Implementations§
source§impl<Message> Subscription<Message>
impl<Message> Subscription<Message>
sourcepub fn none() -> Self
pub fn none() -> Self
Returns an empty Subscription
that will not produce any output.
sourcepub fn from_recipe(recipe: impl Recipe<Output = Message> + 'static) -> Self
pub fn from_recipe(recipe: impl Recipe<Output = Message> + 'static) -> Self
Creates a Subscription
from a Recipe
describing it.
sourcepub fn batch(
subscriptions: impl IntoIterator<Item = Subscription<Message>>
) -> Self
pub fn batch( subscriptions: impl IntoIterator<Item = Subscription<Message>> ) -> Self
Batches all the provided subscriptions and returns the resulting
Subscription
.
sourcepub fn into_recipes(self) -> Vec<Box<dyn Recipe<Output = Message>>>
pub fn into_recipes(self) -> Vec<Box<dyn Recipe<Output = Message>>>
Returns the different recipes of the Subscription
.
sourcepub fn with<T>(self, value: T) -> Subscription<(T, Message)>where
Message: 'static,
T: Hash + Clone + Send + Sync + 'static,
pub fn with<T>(self, value: T) -> Subscription<(T, Message)>where Message: '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
.
sourcepub fn map<A>(self, f: fn(_: Message) -> A) -> Subscription<A>where
Message: 'static,
A: 'static,
pub fn map<A>(self, f: fn(_: Message) -> A) -> Subscription<A>where Message: 'static, A: 'static,
Transforms the Subscription
output with the given function.
Trait Implementations§
Auto Trait Implementations§
impl<Message> !RefUnwindSafe for Subscription<Message>
impl<Message> !Send for Subscription<Message>
impl<Message> !Sync for Subscription<Message>
impl<Message> Unpin for Subscription<Message>
impl<Message> !UnwindSafe for Subscription<Message>
Blanket Implementations§
source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere T: Real + Zero + Arithmetics + Clone, Swp: WhitePoint<T>, Dwp: WhitePoint<T>, D: AdaptFrom<S, Swp, Dwp, T>,
source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere M: TransformMatrix<T>,
source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
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
source§impl<T> FromAngle<T> for T
impl<T> FromAngle<T> for T
source§fn from_angle(angle: T) -> T
fn from_angle(angle: T) -> T
angle
.source§impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
impl<T, U> FromStimulus<U> for Twhere U: IntoStimulus<T>,
source§fn from_stimulus(other: U) -> T
fn from_stimulus(other: U) -> T
other
into Self
, while performing the appropriate scaling,
rounding and clamping.source§impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
impl<T, U> IntoAngle<U> for Twhere U: FromAngle<T>,
source§fn into_angle(self) -> U
fn into_angle(self) -> U
T
.source§impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
impl<T, U> IntoColor<U> for Twhere U: FromColor<T>,
source§fn into_color(self) -> U
fn into_color(self) -> U
source§impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
impl<T, U> IntoColorUnclamped<U> for Twhere U: FromColorUnclamped<T>,
source§fn into_color_unclamped(self) -> U
fn into_color_unclamped(self) -> U
source§impl<T> IntoStimulus<T> for T
impl<T> IntoStimulus<T> for T
source§fn into_stimulus(self) -> T
fn into_stimulus(self) -> T
self
into T
, while performing the appropriate scaling,
rounding and clamping.source§impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
impl<T, U> TryIntoColor<U> for Twhere U: TryFromColor<T>,
source§fn try_into_color(self) -> Result<U, OutOfBounds<U>>
fn try_into_color(self) -> Result<U, OutOfBounds<U>>
OutOfBounds
error is returned which contains
the unclamped color. Read more