Skip to main content

Transport

Trait Transport 

Source
pub trait Transport: Send + Sync {
    // Required method
    fn post(&self, body: &[u8]) -> Result<Reply, String>;
}
Expand description

The wire: one POST of a JSON request body to the API endpoint.

Client::new builds an HTTPS transport; Client::with_transport takes any implementation, so tests and local fakes need no network. Err is a connection-level failure, which the client retries; an HTTP error status is an Ok reply that the client interprets. The trait is implemented for any Fn(&[u8]) -> Result<Reply, String> closure.

Required Methods§

Source

fn post(&self, body: &[u8]) -> Result<Reply, String>

Sends body (a JSON document) and returns the reply, or a connection-level failure.

Trait Implementations§

Source§

impl Transport for Box<dyn Transport>

Source§

fn post(&self, body: &[u8]) -> Result<Reply, String>

Sends body (a JSON document) and returns the reply, or a connection-level failure.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl Transport for Box<dyn Transport>

Source§

fn post(&self, body: &[u8]) -> Result<Reply, String>

Implementors§

Source§

impl<F: Fn(&[u8]) -> Result<Reply, String> + Send + Sync> Transport for F