pub trait Backend {
type HttpRequest;
type HttpResponse;
type Error: Display + From<ApiError> + From<Error> + 'static;
Show 14 methods
// Required methods
fn build_base_request<Req>(
&self,
req: Req,
form: Option<Form<'static>>,
) -> Result<Self::HttpRequest, Self::Error>
where Req: ApiRequest;
fn get_header(
res: &Self::HttpResponse,
key: HeaderName,
) -> Option<&HeaderValue>;
fn request_raw<'life0, 'async_trait, Req>(
&'life0 self,
req: Req,
form: Option<Form<'static>>,
) -> Pin<Box<dyn Future<Output = Result<(StatusCode, Bytes), Self::Error>> + 'async_trait>>
where Req: ApiRequest + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait;
fn response_to_byte_stream(
res: Self::HttpResponse,
) -> BoxStream<Bytes, Self::Error>;
fn request_stream<Res, F>(
&self,
req: Self::HttpRequest,
process: F,
) -> BoxStream<Res, Self::Error>
where F: 'static + Send + Fn(Self::HttpResponse) -> BoxStream<Res, Self::Error>;
fn with_credentials<U, P>(self, username: U, password: P) -> Self
where U: Into<String>,
P: Into<String>;
// Provided methods
fn process_error_from_body(body: Bytes) -> Self::Error { ... }
fn process_json_response<Res>(
status: StatusCode,
body: Bytes,
) -> Result<Res, Self::Error>
where for<'de> Res: 'static + Deserialize<'de> + Send { ... }
fn process_stream_response<D, Res>(
res: Self::HttpResponse,
decoder: D,
) -> FramedRead<StreamReader<BoxStream<Bytes, Self::Error>>, D>
where D: Decoder<Item = Res, Error = Error> { ... }
fn request<'life0, 'async_trait, Req, Res>(
&'life0 self,
req: Req,
form: Option<Form<'static>>,
) -> Pin<Box<dyn Future<Output = Result<Res, Self::Error>> + 'async_trait>>
where Req: ApiRequest + 'async_trait,
for<'de> Res: 'static + Deserialize<'de> + Send + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait { ... }
fn request_empty<'life0, 'async_trait, Req>(
&'life0 self,
req: Req,
form: Option<Form<'static>>,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + 'async_trait>>
where Req: ApiRequest + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait { ... }
fn request_string<'life0, 'async_trait, Req>(
&'life0 self,
req: Req,
form: Option<Form<'static>>,
) -> Pin<Box<dyn Future<Output = Result<String, Self::Error>> + 'async_trait>>
where Req: ApiRequest + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait { ... }
fn request_stream_bytes(
&self,
req: Self::HttpRequest,
) -> BoxStream<Bytes, Self::Error> { ... }
fn request_stream_json<Res>(
&self,
req: Self::HttpRequest,
) -> BoxStream<Res, Self::Error>
where for<'de> Res: 'static + Deserialize<'de> + Send { ... }
}
Required Associated Types§
type HttpRequest
type HttpResponse
type Error: Display + From<ApiError> + From<Error> + 'static
Required Methods§
Sourcefn build_base_request<Req>(
&self,
req: Req,
form: Option<Form<'static>>,
) -> Result<Self::HttpRequest, Self::Error>where
Req: ApiRequest,
fn build_base_request<Req>(
&self,
req: Req,
form: Option<Form<'static>>,
) -> Result<Self::HttpRequest, Self::Error>where
Req: ApiRequest,
Builds the url for an api call.
Sourcefn get_header(res: &Self::HttpResponse, key: HeaderName) -> Option<&HeaderValue>
fn get_header(res: &Self::HttpResponse, key: HeaderName) -> Option<&HeaderValue>
Get the value of a header from an HTTP response.
Sourcefn request_raw<'life0, 'async_trait, Req>(
&'life0 self,
req: Req,
form: Option<Form<'static>>,
) -> Pin<Box<dyn Future<Output = Result<(StatusCode, Bytes), Self::Error>> + 'async_trait>>where
Req: ApiRequest + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
fn request_raw<'life0, 'async_trait, Req>(
&'life0 self,
req: Req,
form: Option<Form<'static>>,
) -> Pin<Box<dyn Future<Output = Result<(StatusCode, Bytes), Self::Error>> + 'async_trait>>where
Req: ApiRequest + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
Generates a request, and returns the unprocessed response future.
fn response_to_byte_stream( res: Self::HttpResponse, ) -> BoxStream<Bytes, Self::Error>
Sourcefn request_stream<Res, F>(
&self,
req: Self::HttpRequest,
process: F,
) -> BoxStream<Res, Self::Error>
fn request_stream<Res, F>( &self, req: Self::HttpRequest, process: F, ) -> BoxStream<Res, Self::Error>
Generic method for making a request that expects back a streaming response.
Provided Methods§
Sourcefn process_error_from_body(body: Bytes) -> Self::Error
fn process_error_from_body(body: Bytes) -> Self::Error
Builds an Api error from a response body.
Sourcefn process_json_response<Res>(
status: StatusCode,
body: Bytes,
) -> Result<Res, Self::Error>where
for<'de> Res: 'static + Deserialize<'de> + Send,
fn process_json_response<Res>(
status: StatusCode,
body: Bytes,
) -> Result<Res, Self::Error>where
for<'de> Res: 'static + Deserialize<'de> + Send,
Processes a response that expects a json encoded body, returning an error or a deserialized json response.
Sourcefn process_stream_response<D, Res>(
res: Self::HttpResponse,
decoder: D,
) -> FramedRead<StreamReader<BoxStream<Bytes, Self::Error>>, D>
fn process_stream_response<D, Res>( res: Self::HttpResponse, decoder: D, ) -> FramedRead<StreamReader<BoxStream<Bytes, Self::Error>>, D>
Processes a response that returns a stream of json deserializable results.
Sourcefn request<'life0, 'async_trait, Req, Res>(
&'life0 self,
req: Req,
form: Option<Form<'static>>,
) -> Pin<Box<dyn Future<Output = Result<Res, Self::Error>> + 'async_trait>>where
Req: ApiRequest + 'async_trait,
for<'de> Res: 'static + Deserialize<'de> + Send + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
fn request<'life0, 'async_trait, Req, Res>(
&'life0 self,
req: Req,
form: Option<Form<'static>>,
) -> Pin<Box<dyn Future<Output = Result<Res, Self::Error>> + 'async_trait>>where
Req: ApiRequest + 'async_trait,
for<'de> Res: 'static + Deserialize<'de> + Send + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
Generic method for making a request to the Ipfs server, and getting a deserializable response.
Sourcefn request_empty<'life0, 'async_trait, Req>(
&'life0 self,
req: Req,
form: Option<Form<'static>>,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + 'async_trait>>where
Req: ApiRequest + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
fn request_empty<'life0, 'async_trait, Req>(
&'life0 self,
req: Req,
form: Option<Form<'static>>,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + 'async_trait>>where
Req: ApiRequest + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
Generic method for making a request to the Ipfs server, and getting back a response with no body.
Sourcefn request_string<'life0, 'async_trait, Req>(
&'life0 self,
req: Req,
form: Option<Form<'static>>,
) -> Pin<Box<dyn Future<Output = Result<String, Self::Error>> + 'async_trait>>where
Req: ApiRequest + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
fn request_string<'life0, 'async_trait, Req>(
&'life0 self,
req: Req,
form: Option<Form<'static>>,
) -> Pin<Box<dyn Future<Output = Result<String, Self::Error>> + 'async_trait>>where
Req: ApiRequest + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
Generic method for making a request to the Ipfs server, and getting back a raw String response.
Sourcefn request_stream_bytes(
&self,
req: Self::HttpRequest,
) -> BoxStream<Bytes, Self::Error>
fn request_stream_bytes( &self, req: Self::HttpRequest, ) -> BoxStream<Bytes, Self::Error>
Generic method for making a request to the Ipfs server, and getting back a raw stream of bytes.
Sourcefn request_stream_json<Res>(
&self,
req: Self::HttpRequest,
) -> BoxStream<Res, Self::Error>where
for<'de> Res: 'static + Deserialize<'de> + Send,
fn request_stream_json<Res>(
&self,
req: Self::HttpRequest,
) -> BoxStream<Res, Self::Error>where
for<'de> Res: 'static + Deserialize<'de> + Send,
Generic method to return a streaming response of deserialized json objects delineated by new line separators.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.