Skip to main content

DynExchange

Trait DynExchange 

Source
pub trait DynExchange: Send + Sync {
    // Required method
    fn exchange_boxed<'a>(
        &'a self,
        method: &'a str,
        params: &'a JsonObject,
    ) -> Pin<Box<dyn Future<Output = Result<JsonObject, ExchangeError>> + Send + 'a>>;
}
Expand description

The boxed spelling of CallbackExchange, for a caller holding a transport of unknown concrete type.

§Examples

use std::sync::Arc;

use protocol_droid::application::server::context::{DynExchange, ExchangeError};
use protocol_droid::domain::ir::JsonObject;

let exchange: Arc<dyn DynExchange> = Arc::new(MyExchange);
// ...handed to a PeerSession, which calls it through the trait object.

Required Methods§

Source

fn exchange_boxed<'a>( &'a self, method: &'a str, params: &'a JsonObject, ) -> Pin<Box<dyn Future<Output = Result<JsonObject, ExchangeError>> + Send + 'a>>

The boxed form of CallbackExchange::exchange.

Written out rather than derived, for the same reason DynFrameSink is: the box belongs to callers that need dynamic dispatch, not to the ones that do not.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§