[][src]Trait artemis::exchange::Exchange

pub trait Exchange: Send + Sync + 'static {
#[must_use]    fn run<'life0, 'async_trait, Q: GraphQLQuery, C: Client>(
        &'life0 self,
        operation: Operation<Q::Variables>,
        client: C
    ) -> Pin<Box<dyn Future<Output = ExchangeResult<Q::ResponseData>> + Send + 'async_trait>>
    where
        Q: 'async_trait,
        C: 'async_trait,
        'life0: 'async_trait,
        Self: 'async_trait
; }

The main trait that must be implemented by exchanges

Required methods

#[must_use]fn run<'life0, 'async_trait, Q: GraphQLQuery, C: Client>(
    &'life0 self,
    operation: Operation<Q::Variables>,
    client: C
) -> Pin<Box<dyn Future<Output = ExchangeResult<Q::ResponseData>> + Send + 'async_trait>> where
    Q: 'async_trait,
    C: 'async_trait,
    'life0: 'async_trait,
    Self: 'async_trait, 

Process a query operation.

Note that this can return early, perhaps partial results to subscriptions via client.push_result(), but this will do nothing for regular requests. The exchange should have a workflow in the style of: Determine if this exchange can return a result -> Delegate to next if not -> Perform processing on the delegated result -> Return result

For examples, see the built-in exchanges.

Arguments

  • operation - the operation to be handled.
  • client - the client object for rerunning queries and pushing results if applicable.

Returns

  • Ok(Response) if the operation was completed successfully
  • Err(YourError) if there was an error anywhere. Errors from next should be passed through. This will be displayed to the user, so make sure the error messages are reasonable.
Loading content...

Implementors

impl Exchange for FetchExchange[src]

impl Exchange for TerminatorExchange[src]

Loading content...