pub trait Req<Error, InputStreamError = Error, OutputStreamError = Error>: 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§

type WebsocketResponse: Send

The response type for websockets.

Required Methods§

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

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

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

Returns the Content-Type header, if any.

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

Returns the Accepts header, if any.

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

Returns the Referer header, if any.

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

Attempts to extract the body of the request into Bytes.

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

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

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.

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.

Implementors§

§

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

§

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

§

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