Skip to main content

TryRes

Trait TryRes 

pub trait TryRes<E>: Sized {
    // Required methods
    fn try_from_string(content_type: &str, data: String) -> Result<Self, E>;
    fn try_from_bytes(content_type: &str, data: Bytes) -> Result<Self, E>;
    fn try_from_stream(
        content_type: &str,
        data: impl Stream<Item = Result<Bytes, Bytes>> + Send + 'static,
    ) -> Result<Self, E>;
}
Expand description

Represents the response as created by the server;

Required Methodsยง

fn try_from_string(content_type: &str, data: String) -> Result<Self, E>

Attempts to convert a UTF-8 string into an HTTP response.

fn try_from_bytes(content_type: &str, data: Bytes) -> Result<Self, E>

Attempts to convert a binary blob represented as bytes into an HTTP response.

fn try_from_stream( content_type: &str, data: impl Stream<Item = Result<Bytes, Bytes>> + Send + 'static, ) -> Result<Self, E>

Attempts to convert a stream of bytes into an HTTP response.

Dyn Compatibilityยง

This trait is not dyn compatible.

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

Implementations on Foreign Typesยง

ยง

impl<E> TryRes<E> for Response<Body>

ยง

fn try_from_string( content_type: &str, data: String, ) -> Result<Response<Body>, E>

ยง

fn try_from_bytes(content_type: &str, data: Bytes) -> Result<Response<Body>, E>

ยง

fn try_from_stream( content_type: &str, data: impl Stream<Item = Result<Bytes, Bytes>> + Send + 'static, ) -> Result<Response<Body>, E>

ยง

impl<E> TryRes<E> for Response<Body>

ยง

fn try_from_string( content_type: &str, data: String, ) -> Result<Response<Body>, E>

ยง

fn try_from_bytes(content_type: &str, data: Bytes) -> Result<Response<Body>, E>

ยง

fn try_from_stream( content_type: &str, data: impl Stream<Item = Result<Bytes, Bytes>> + Send + 'static, ) -> Result<Response<Body>, E>

Implementorsยง