MappedAsyncCaller

Struct MappedAsyncCaller 

Source
pub struct MappedAsyncCaller<'a, Out: for<'de> ArgumentDecoder<'de> + Send, Out2: for<'de> ArgumentDecoder<'de> + Send, Inner: AsyncCall<Value = Out> + Send + 'a, Map: Send + Fn(Out) -> Out2> { /* private fields */ }
Expand description

A structure that applies a transform function to the result of a call. Because of constraints on the type system in Rust, both the input and output to the function must be deserializable.

Implementations§

Source§

impl<'a, Out, Out2, Inner, Map> MappedAsyncCaller<'a, Out, Out2, Inner, Map>
where Out: for<'de> ArgumentDecoder<'de> + Send, Out2: for<'de> ArgumentDecoder<'de> + Send, Inner: AsyncCall<Value = Out> + Send + 'a, Map: Send + Fn(Out) -> Out2,

Source

pub fn new(inner: Inner, map: Map) -> Self

Equivalent to inner.map(map).

Source

pub async fn call(self) -> Result<CallResponse<Out2>, AgentError>

Source

pub async fn call_and_wait(self) -> Result<Out2, AgentError>

Source

pub fn and_then<Out3, R2, AndThen2>( self, and_then: AndThen2, ) -> AndThenAsyncCaller<'a, Out2, Out3, Self, R2, AndThen2>
where Out3: for<'de> ArgumentDecoder<'de> + Send + 'a, R2: Future<Output = Result<Out3, AgentError>> + Send + 'a, AndThen2: Send + Fn(Out2) -> R2 + 'a,

Source

pub fn map<Out3, Map2>( self, map: Map2, ) -> MappedAsyncCaller<'a, Out2, Out3, Self, Map2>
where Out3: for<'de> ArgumentDecoder<'de> + Send, Map2: Send + Fn(Out2) -> Out3,

Trait Implementations§

Source§

impl<'a, Out, Out2, Inner, Map> AsyncCall for MappedAsyncCaller<'a, Out, Out2, Inner, Map>
where Out: for<'de> ArgumentDecoder<'de> + Send + 'a, Out2: for<'de> ArgumentDecoder<'de> + Send + 'a, Inner: AsyncCall<Value = Out> + Send + 'a, Map: Send + Fn(Out) -> Out2 + 'a,

Source§

type Value = Out2

The return type of the Candid function being called.
Source§

fn call<'async_trait>( self, ) -> Pin<Box<dyn Future<Output = Result<CallResponse<Out2>, AgentError>> + 'async_trait>>
where Self: 'async_trait,

Execute the call, but returns the RequestId. Waiting on the request Id must be managed by the caller using the Agent directly. Read more
Source§

fn call_and_wait<'async_trait>( self, ) -> Pin<Box<dyn Future<Output = Result<Out2, AgentError>> + 'async_trait>>
where Self: 'async_trait,

Execute the call, and wait for an answer using an exponential-backoff strategy. The return type is encoded in the trait.
Source§

fn and_then<'a, Out2, R, AndThen>( self, and_then: AndThen, ) -> AndThenAsyncCaller<'a, Self::Value, Out2, Self, R, AndThen>
where Self: Sized + Send + 'a, Out2: for<'de> ArgumentDecoder<'de> + Send + 'a, R: Future<Output = Result<Out2, AgentError>> + Send + 'a, AndThen: Send + Fn(Self::Value) -> R + 'a,

Apply a transformation function after the call has been successful. The transformation is applied with the result. Read more
Source§

fn map<'a, Out, Map>( self, map: Map, ) -> MappedAsyncCaller<'a, Self::Value, Out, Self, Map>
where Self: Sized + Send + 'a, Out: for<'de> ArgumentDecoder<'de> + Send + 'a, Map: Send + Fn(Self::Value) -> Out + 'a,

Apply a transformation function after the call has been successful. Equivalent to .and_then(|x| async { map(x) }).
Source§

impl<'a, Out, Out2, Inner, Map> Debug for MappedAsyncCaller<'a, Out, Out2, Inner, Map>
where Out: for<'de> ArgumentDecoder<'de> + Send, Out2: for<'de> ArgumentDecoder<'de> + Send, Inner: AsyncCall<Value = Out> + Send + Debug + 'a, Map: Send + Fn(Out) -> Out2 + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a, Out, Out2, Inner, Map> IntoFuture for MappedAsyncCaller<'a, Out, Out2, Inner, Map>
where Out: for<'de> ArgumentDecoder<'de> + Send + 'a, Out2: for<'de> ArgumentDecoder<'de> + Send + 'a, Inner: AsyncCall<Value = Out> + Send + 'a, Map: Send + Fn(Out) -> Out2 + 'a,

Source§

type IntoFuture = Pin<Box<dyn Future<Output = Result<Out2, AgentError>> + 'a>>

Which kind of future are we turning this into?
Source§

type Output = Result<Out2, AgentError>

The output that the future will produce on completion.
Source§

fn into_future(self) -> Self::IntoFuture

Creates a future from a value. Read more

Auto Trait Implementations§

§

impl<'a, Out, Out2, Inner, Map> Freeze for MappedAsyncCaller<'a, Out, Out2, Inner, Map>
where Inner: Freeze, Map: Freeze,

§

impl<'a, Out, Out2, Inner, Map> RefUnwindSafe for MappedAsyncCaller<'a, Out, Out2, Inner, Map>
where Inner: RefUnwindSafe, Map: RefUnwindSafe, Out: RefUnwindSafe, Out2: RefUnwindSafe,

§

impl<'a, Out, Out2, Inner, Map> Send for MappedAsyncCaller<'a, Out, Out2, Inner, Map>

§

impl<'a, Out, Out2, Inner, Map> Sync for MappedAsyncCaller<'a, Out, Out2, Inner, Map>
where Inner: Sync, Map: Sync, Out: Sync, Out2: Sync,

§

impl<'a, Out, Out2, Inner, Map> Unpin for MappedAsyncCaller<'a, Out, Out2, Inner, Map>
where Inner: Unpin, Map: Unpin, Out: Unpin, Out2: Unpin,

§

impl<'a, Out, Out2, Inner, Map> UnwindSafe for MappedAsyncCaller<'a, Out, Out2, Inner, Map>
where Inner: UnwindSafe, Map: UnwindSafe, Out: UnwindSafe, Out2: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T