Skip to main content

Req

Trait Req 

Source
pub trait Req<Error, InputStreamError = Error, OutputStreamError = Error>
where Self: Sized,
{ type WebsocketResponse: Send; // Required methods fn as_query(&self) -> Option<&str>; fn to_content_type(&self) -> Option<Cow<'_, str>>; fn accepts(&self) -> Option<Cow<'_, str>>; fn referer(&self) -> Option<Cow<'_, str>>; fn try_into_bytes(self) -> impl Future<Output = Result<Bytes, Error>> + Send; fn try_into_string( self, ) -> impl Future<Output = Result<String, Error>> + Send; fn try_into_stream( self, ) -> Result<impl Stream<Item = Result<Bytes, Bytes>> + Send + 'static, Error>; fn try_into_websocket( self, ) -> impl Future<Output = Result<(impl Stream<Item = Result<Bytes, Bytes>> + Send + 'static, impl Sink<Bytes> + Send + 'static, Self::WebsocketResponse), Error>> + Send; }
Expand description

Represents the request as received by the server.

Required Associated Types§

Source

type WebsocketResponse: Send

The response type for websockets.

Required Methods§

Source

fn as_query(&self) -> Option<&str>

Returns the query string of the request’s URL, starting after the ?.

Source

fn to_content_type(&self) -> Option<Cow<'_, str>>

Returns the Content-Type header, if any.

Source

fn accepts(&self) -> Option<Cow<'_, str>>

Returns the Accepts header, if any.

Source

fn referer(&self) -> Option<Cow<'_, str>>

Returns the Referer header, if any.

Source

fn try_into_bytes(self) -> impl Future<Output = Result<Bytes, Error>> + Send

Attempts to extract the body of the request into Bytes.

Source

fn try_into_string(self) -> impl Future<Output = Result<String, Error>> + Send

Attempts to convert the body of the request into a string.

Source

fn try_into_stream( self, ) -> Result<impl Stream<Item = Result<Bytes, Bytes>> + Send + 'static, Error>

Attempts to convert the body of the request into a stream of bytes.

Source

fn try_into_websocket( self, ) -> impl Future<Output = Result<(impl Stream<Item = Result<Bytes, Bytes>> + Send + 'static, impl Sink<Bytes> + Send + 'static, Self::WebsocketResponse), Error>> + Send

Attempts to convert the body of the request into a websocket handle.

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.

Implementations on Foreign Types§

Source§

impl<Error, InputStreamError, OutputStreamError> Req<Error, InputStreamError, OutputStreamError> for Request<Bytes>
where Error: FromServerFnError + Send, InputStreamError: FromServerFnError + Send, OutputStreamError: FromServerFnError + Send,

Source§

type WebsocketResponse = Response<Bytes>

Source§

async fn try_into_bytes(self) -> Result<Bytes, Error>

Source§

async fn try_into_string(self) -> Result<String, Error>

Source§

fn try_into_stream( self, ) -> Result<impl Stream<Item = Result<Bytes, Bytes>> + Send + 'static, Error>

Source§

fn to_content_type(&self) -> Option<Cow<'_, str>>

Source§

fn accepts(&self) -> Option<Cow<'_, str>>

Source§

fn referer(&self) -> Option<Cow<'_, str>>

Source§

fn as_query(&self) -> Option<&str>

Source§

async fn try_into_websocket( self, ) -> Result<(impl Stream<Item = Result<Bytes, Bytes>> + Send + 'static, impl Sink<Bytes> + Send + 'static, Self::WebsocketResponse), Error>

Source§

impl<Error, InputStreamError, OutputStreamError> Req<Error, InputStreamError, OutputStreamError> for Request<Body>
where Error: FromServerFnError + Send, InputStreamError: FromServerFnError + Send, OutputStreamError: FromServerFnError + Send,

Source§

type WebsocketResponse = Response<Body>

Source§

fn as_query(&self) -> Option<&str>

Source§

fn to_content_type(&self) -> Option<Cow<'_, str>>

Source§

fn accepts(&self) -> Option<Cow<'_, str>>

Source§

fn referer(&self) -> Option<Cow<'_, str>>

Source§

async fn try_into_bytes(self) -> Result<Bytes, Error>

Source§

async fn try_into_string(self) -> Result<String, Error>

Source§

fn try_into_stream( self, ) -> Result<impl Stream<Item = Result<Bytes, Bytes>> + Send + 'static, Error>

Source§

async fn try_into_websocket( self, ) -> Result<(impl Stream<Item = Result<Bytes, Bytes>> + Send + 'static, impl Sink<Bytes> + Send + 'static, Self::WebsocketResponse), Error>

Implementors§

Source§

impl<Error, InputStreamError, OutputStreamError> Req<Error, InputStreamError, OutputStreamError> for ActixRequest
where Error: FromServerFnError + Send, InputStreamError: FromServerFnError + Send, OutputStreamError: FromServerFnError + Send,

Source§

impl<Error, InputStreamError, OutputStreamError> Req<Error, InputStreamError, OutputStreamError> for BrowserMockReq
where Error: Send + 'static, InputStreamError: Send + 'static, OutputStreamError: Send + 'static,