AndThenAsyncCaller

Struct AndThenAsyncCaller 

Source
pub struct AndThenAsyncCaller<'a, Out: for<'de> ArgumentDecoder<'de> + Send, Out2: for<'de> ArgumentDecoder<'de> + Send, Inner: AsyncCall<Value = Out> + Send + 'a, R: Future<Output = Result<Out2, AgentError>> + Send, AndThen: Send + Fn(Out) -> R> { /* private fields */ }
Expand description

An AsyncCall that applies a transform function to the result of the 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, R, AndThen> AndThenAsyncCaller<'a, Out, Out2, Inner, R, AndThen>
where Out: for<'de> ArgumentDecoder<'de> + Send + 'a, Out2: for<'de> ArgumentDecoder<'de> + Send + 'a, Inner: AsyncCall<Value = Out> + Send + 'a, R: Future<Output = Result<Out2, AgentError>> + Send + 'a, AndThen: Send + Fn(Out) -> R + 'a,

Source

pub fn new(inner: Inner, and_then: AndThen) -> Self

Equivalent to inner.and_then(and_then).

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, Map>( self, map: Map, ) -> MappedAsyncCaller<'a, Out2, Out3, Self, Map>
where Out3: for<'de> ArgumentDecoder<'de> + Send, Map: Send + Fn(Out2) -> Out3,

Trait Implementations§

Source§

impl<'a, Out, Out2, Inner, R, AndThen> AsyncCall for AndThenAsyncCaller<'a, Out, Out2, Inner, R, AndThen>
where Out: for<'de> ArgumentDecoder<'de> + Send + 'a, Out2: for<'de> ArgumentDecoder<'de> + Send + 'a, Inner: AsyncCall<Value = Out> + Send + 'a, R: Future<Output = Result<Out2, AgentError>> + Send + 'a, AndThen: Send + Fn(Out) -> R + '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>> + Send + '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>> + Send + '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, R, AndThen> Debug for AndThenAsyncCaller<'a, Out, Out2, Inner, R, AndThen>
where Out: for<'de> ArgumentDecoder<'de> + Send, Out2: for<'de> ArgumentDecoder<'de> + Send, Inner: AsyncCall<Value = Out> + Send + Debug + 'a, R: Future<Output = Result<Out2, AgentError>> + Send, AndThen: Send + Fn(Out) -> R + Debug,

Source§

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

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

impl<'a, Out, Out2, Inner, R, AndThen> IntoFuture for AndThenAsyncCaller<'a, Out, Out2, Inner, R, AndThen>
where Out: for<'de> ArgumentDecoder<'de> + Send + 'a, Out2: for<'de> ArgumentDecoder<'de> + Send + 'a, Inner: AsyncCall<Value = Out> + Send + 'a, R: Future<Output = Result<Out2, AgentError>> + Send + 'a, AndThen: Send + Fn(Out) -> R + 'a,

Source§

type IntoFuture = Pin<Box<dyn Future<Output = Result<Out2, AgentError>> + Send + '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, R, AndThen> Freeze for AndThenAsyncCaller<'a, Out, Out2, Inner, R, AndThen>
where Inner: Freeze, AndThen: Freeze,

§

impl<'a, Out, Out2, Inner, R, AndThen> RefUnwindSafe for AndThenAsyncCaller<'a, Out, Out2, Inner, R, AndThen>
where Inner: RefUnwindSafe, AndThen: RefUnwindSafe, Out: RefUnwindSafe, Out2: RefUnwindSafe,

§

impl<'a, Out, Out2, Inner, R, AndThen> Send for AndThenAsyncCaller<'a, Out, Out2, Inner, R, AndThen>

§

impl<'a, Out, Out2, Inner, R, AndThen> Sync for AndThenAsyncCaller<'a, Out, Out2, Inner, R, AndThen>
where Inner: Sync, AndThen: Sync, Out: Sync, Out2: Sync,

§

impl<'a, Out, Out2, Inner, R, AndThen> Unpin for AndThenAsyncCaller<'a, Out, Out2, Inner, R, AndThen>
where Inner: Unpin, AndThen: Unpin, Out: Unpin, Out2: Unpin,

§

impl<'a, Out, Out2, Inner, R, AndThen> UnwindSafe for AndThenAsyncCaller<'a, Out, Out2, Inner, R, AndThen>
where Inner: UnwindSafe, AndThen: 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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

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

Source§

impl<T> MaybeSendSync for T