pub struct Refreshable<T, E> { /* private fields */ }
Expand description

A wrapper around a live-refreshable value.

Implementations§

Creates a new Refreshable with an initial value, returning it along with a RefreshHandle used to update it with new values.

Returns a guard type providing access to a snapshot of the refreshable’s current value.

Subscribes to the refreshable.

The callback will be invoked every time the refreshable’s value changes, and is also called synchronously when this method is called with the current value. If the callback returns Ok, a Subscription object is returned that will unsubscribe from the refreshable when it drops. If the callback returns Err, this method will return the error and the callback will not be invoked on updates to the value.

Subscribes to the refreshable with an infallible callback.

This is a convenience method to simplify subscription when the callback can never fail.

Creates a new refreshable from this one by applying a mapping function to the value.

This can be used to narrow the scope of the refreshable value. Updates to the initial refreshable value will propagate to the mapped refreshable value, but the mapped refreshable’s subscriptions will only be invoked if the mapped value actually changed.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.