pub type ResponseVar<T> = ReadOnlyVar<Response<T>, ArcVar<Response<T>>>;
Expand description
Variable used to listen to a one time signal that an async operation has completed.
Use response_var
or response_done_var
to init.
Aliased Type§
struct ResponseVar<T>(/* private fields */);
Implementations§
source§impl<T: VarValue> ResponseVar<T>
impl<T: VarValue> ResponseVar<T>
sourcepub fn with_rsp<R>(&self, read: impl FnOnce(&T) -> R) -> Option<R>
pub fn with_rsp<R>(&self, read: impl FnOnce(&T) -> R) -> Option<R>
Visit the response, if present.
sourcepub fn with_new_rsp<R>(&self, read: impl FnOnce(&T) -> R) -> Option<R>
pub fn with_new_rsp<R>(&self, read: impl FnOnce(&T) -> R) -> Option<R>
Visit the response, if present and new.
sourcepub fn is_waiting(&self) -> bool
pub fn is_waiting(&self) -> bool
If the response is not received yet.
sourcepub async fn wait_rsp(&self) -> T
pub async fn wait_rsp(&self) -> T
Returns a future that awaits until a response is received and then returns a clone.
sourcepub async fn wait_into_rsp(self) -> T
pub async fn wait_into_rsp(self) -> T
Returns a future that awaits until a response is received and then returns it.
Will clone the value if the variable is shared.
Note that ResponseVar<T>
implements IntoFuture
so you can also just .await
the variable.
sourcepub fn into_rsp(self) -> Option<T>
pub fn into_rsp(self) -> Option<T>
Into response, if received.
Clones if the variable is has more than one strong reference.
sourcepub fn map_rsp<O, I, M>(&self, waiting_value: I, map: M) -> impl Var<O>
pub fn map_rsp<O, I, M>(&self, waiting_value: I, map: M) -> impl Var<O>
Map the response value using map
, if the variable is awaiting a response uses the waiting_value
first.
sourcepub fn map_response<O, M>(&self, map: M) -> ResponseVar<O>
pub fn map_response<O, M>(&self, map: M) -> ResponseVar<O>
Map to another response variable.