pub trait Transport: Send + Sync {
// Required methods
fn call(
&self,
effective_canister_id: Principal,
envelope: Vec<u8>,
request_id: RequestId
) -> Pin<Box<dyn Future<Output = Result<(), AgentError>> + Send + '_>>;
fn read_state(
&self,
effective_canister_id: Principal,
envelope: Vec<u8>
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, AgentError>> + Send + '_>>;
fn read_subnet_state(
&self,
subnet_id: Principal,
envelope: Vec<u8>
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, AgentError>> + Send + '_>>;
fn query(
&self,
effective_canister_id: Principal,
envelope: Vec<u8>
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, AgentError>> + Send + '_>>;
fn status(
&self
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, AgentError>> + Send + '_>>;
}Expand description
A facade that connects to a Replica and does requests. These requests can be of any type (does not have to be HTTP). This trait is to inverse the control from the Agent over its connection code, and to resolve any direct dependencies to tokio or HTTP code from this crate.
An implementation of this trait for HTTP transport is implemented using Reqwest, with the
feature flag reqwest. This might be deprecated in the future.
Any error returned by these methods will bubble up to the code that called the Agent.
Required Methods§
sourcefn call(
&self,
effective_canister_id: Principal,
envelope: Vec<u8>,
request_id: RequestId
) -> Pin<Box<dyn Future<Output = Result<(), AgentError>> + Send + '_>>
fn call( &self, effective_canister_id: Principal, envelope: Vec<u8>, request_id: RequestId ) -> Pin<Box<dyn Future<Output = Result<(), AgentError>> + Send + '_>>
Sends an asynchronous request to a replica. The Request ID is non-mutable and depends on the content of the envelope.
This normally corresponds to the /api/v2/canister/<effective_canister_id>/call endpoint.
sourcefn read_state(
&self,
effective_canister_id: Principal,
envelope: Vec<u8>
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, AgentError>> + Send + '_>>
fn read_state( &self, effective_canister_id: Principal, envelope: Vec<u8> ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, AgentError>> + Send + '_>>
Sends a synchronous request to a replica. This call includes the body of the request message itself (envelope).
This normally corresponds to the /api/v2/canister/<effective_canister_id>/read_state endpoint.
sourcefn read_subnet_state(
&self,
subnet_id: Principal,
envelope: Vec<u8>
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, AgentError>> + Send + '_>>
fn read_subnet_state( &self, subnet_id: Principal, envelope: Vec<u8> ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, AgentError>> + Send + '_>>
Sends a synchronous request to a replica. This call includes the body of the request message itself (envelope).
This normally corresponds to the /api/v2/subnet/<subnet_id>/read_state endpoint.
sourcefn query(
&self,
effective_canister_id: Principal,
envelope: Vec<u8>
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, AgentError>> + Send + '_>>
fn query( &self, effective_canister_id: Principal, envelope: Vec<u8> ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, AgentError>> + Send + '_>>
Sends a synchronous request to a replica. This call includes the body of the request message itself (envelope).
This normally corresponds to the /api/v2/canister/<effective_canister_id>/query endpoint.
sourcefn status(
&self
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, AgentError>> + Send + '_>>
fn status( &self ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, AgentError>> + Send + '_>>
Sends a status request to the replica, returning whatever the replica returns. In the current spec v2, this is a CBOR encoded status message, but we are not making this API attach semantics to the response.
Implementations on Foreign Types§
source§impl<I: Transport + ?Sized> Transport for Box<I>
impl<I: Transport + ?Sized> Transport for Box<I>
fn call( &self, effective_canister_id: Principal, envelope: Vec<u8>, request_id: RequestId ) -> Pin<Box<dyn Future<Output = Result<(), AgentError>> + Send + '_>>
fn read_state( &self, effective_canister_id: Principal, envelope: Vec<u8> ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, AgentError>> + Send + '_>>
fn query( &self, effective_canister_id: Principal, envelope: Vec<u8> ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, AgentError>> + Send + '_>>
fn status( &self ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, AgentError>> + Send + '_>>
fn read_subnet_state( &self, subnet_id: Principal, envelope: Vec<u8> ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, AgentError>> + Send + '_>>
source§impl<I: Transport + ?Sized> Transport for Arc<I>
impl<I: Transport + ?Sized> Transport for Arc<I>
fn call( &self, effective_canister_id: Principal, envelope: Vec<u8>, request_id: RequestId ) -> Pin<Box<dyn Future<Output = Result<(), AgentError>> + Send + '_>>
fn read_state( &self, effective_canister_id: Principal, envelope: Vec<u8> ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, AgentError>> + Send + '_>>
fn query( &self, effective_canister_id: Principal, envelope: Vec<u8> ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, AgentError>> + Send + '_>>
fn status( &self ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, AgentError>> + Send + '_>>
fn read_subnet_state( &self, subnet_id: Principal, envelope: Vec<u8> ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, AgentError>> + Send + '_>>
Implementors§
impl Transport for ReqwestTransport
reqwest only.impl<B1, S> Transport for HyperTransport<B1, S>where B1: HyperBody, S: HyperService<B1>,
hyper only.