Trait server_fn::response::Res

source ·
pub trait Res<CustErr>
where Self: Sized,
{ // Required methods fn try_from_string( content_type: &str, data: String, ) -> Result<Self, ServerFnError<CustErr>>; fn try_from_bytes( content_type: &str, data: Bytes, ) -> Result<Self, ServerFnError<CustErr>>; fn try_from_stream( content_type: &str, data: impl Stream<Item = Result<Bytes, ServerFnError<CustErr>>> + Send + 'static, ) -> Result<Self, ServerFnError<CustErr>>; fn error_response(path: &str, err: &ServerFnError<CustErr>) -> Self; fn redirect(&mut self, path: &str); }
Expand description

Represents the response as created by the server;

Required Methods§

source

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

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

source

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

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

source

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

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

source

fn error_response(path: &str, err: &ServerFnError<CustErr>) -> Self

Converts an error into a response, with a 500 status code and the error text as its body.

source

fn redirect(&mut self, path: &str)

Redirect the response by setting a 302 code and Location header.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<CustErr> Res<CustErr> for Response<Body>
where CustErr: Send + Sync + Debug + FromStr + Display + 'static,

source§

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

source§

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

source§

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

source§

fn error_response(path: &str, err: &ServerFnError<CustErr>) -> Self

source§

fn redirect(&mut self, path: &str)

Implementors§

source§

impl<CustErr> Res<CustErr> for ActixResponse
where CustErr: FromStr + Display + Debug + 'static,

source§

impl<CustErr> Res<CustErr> for BrowserMockRes