Trait viz_core::RequestExt
source · pub trait RequestExt: Sealed + Sized {
Show 25 methods
// Required methods
fn schema(&self) -> Option<&Scheme>;
fn path(&self) -> &str;
fn query_string(&self) -> Option<&str>;
fn query<T>(&self) -> Result<T, PayloadError>
where T: DeserializeOwned;
fn header<K, T>(&self, key: K) -> Option<T>
where K: AsHeaderName,
T: FromStr;
fn header_typed<H>(&self) -> Option<H>
where H: Header;
fn content_length(&self) -> Option<u64>;
fn content_type(&self) -> Option<Mime>;
fn extract<T>(&mut self) -> impl Future<Output = Result<T, T::Error>> + Send
where T: FromRequest;
fn incoming(&mut self) -> Result<Body, PayloadError>;
fn bytes(
&mut self,
) -> impl Future<Output = Result<Bytes, PayloadError>> + Send;
fn text(
&mut self,
) -> impl Future<Output = Result<String, PayloadError>> + Send;
fn form<T>(
&mut self,
) -> impl Future<Output = Result<T, PayloadError>> + Send
where T: DeserializeOwned;
fn json<T>(
&mut self,
) -> impl Future<Output = Result<T, PayloadError>> + Send
where T: DeserializeOwned;
fn multipart(
&mut self,
) -> impl Future<Output = Result<Multipart, PayloadError>> + Send;
fn state<T>(&self) -> Option<T>
where T: Clone + Send + Sync + 'static;
fn set_state<T>(&mut self, t: T) -> Option<T>
where T: Clone + Send + Sync + 'static;
fn cookies(&self) -> Result<Cookies, CookiesError>;
fn cookie<S>(&self, name: S) -> Option<Cookie<'_>>
where S: AsRef<str>;
fn session(&self) -> &Session;
fn params<T>(&self) -> Result<T, ParamsError>
where T: DeserializeOwned;
fn param<T>(&self, name: &str) -> Result<T, ParamsError>
where T: FromStr,
T::Err: Display;
fn route_info(&self) -> &Arc<RouteInfo>;
fn remote_addr(&self) -> Option<&SocketAddr>;
fn realip(&self) -> Option<RealIp>;
}Expand description
The Request Extension.
Required Methods§
sourcefn query_string(&self) -> Option<&str>
fn query_string(&self) -> Option<&str>
Get URL’s query string of this request.
sourcefn query<T>(&self) -> Result<T, PayloadError>where
T: DeserializeOwned,
Available on crate feature query only.
fn query<T>(&self) -> Result<T, PayloadError>where
T: DeserializeOwned,
query only.Get query data by type.
§Errors
Will return PayloadError::UrlDecode if decoding the query string fails.
sourcefn header<K, T>(&self, key: K) -> Option<T>where
K: AsHeaderName,
T: FromStr,
fn header<K, T>(&self, key: K) -> Option<T>where
K: AsHeaderName,
T: FromStr,
Get a header with the key.
sourcefn header_typed<H>(&self) -> Option<H>where
H: Header,
fn header_typed<H>(&self) -> Option<H>where
H: Header,
Get a header with the specified type.
sourcefn content_length(&self) -> Option<u64>
fn content_length(&self) -> Option<u64>
Get the size of this request’s body.
sourcefn content_type(&self) -> Option<Mime>
fn content_type(&self) -> Option<Mime>
Get the media type of this request.
sourcefn extract<T>(&mut self) -> impl Future<Output = Result<T, T::Error>> + Sendwhere
T: FromRequest,
fn extract<T>(&mut self) -> impl Future<Output = Result<T, T::Error>> + Sendwhere
T: FromRequest,
Extract the data from this request by the specified type.
sourcefn incoming(&mut self) -> Result<Body, PayloadError>
fn incoming(&mut self) -> Result<Body, PayloadError>
Get an incoming body.
§Errors
Will return PayloadError::Empty or PayloadError::Used if the incoming does not
exist or be used.
sourcefn bytes(&mut self) -> impl Future<Output = Result<Bytes, PayloadError>> + Send
fn bytes(&mut self) -> impl Future<Output = Result<Bytes, PayloadError>> + Send
Return with a Bytes representation of the request body.
sourcefn text(&mut self) -> impl Future<Output = Result<String, PayloadError>> + Send
fn text(&mut self) -> impl Future<Output = Result<String, PayloadError>> + Send
Return with a Text representation of the request body.
sourcefn form<T>(&mut self) -> impl Future<Output = Result<T, PayloadError>> + Sendwhere
T: DeserializeOwned,
Available on crate feature form only.
fn form<T>(&mut self) -> impl Future<Output = Result<T, PayloadError>> + Sendwhere
T: DeserializeOwned,
form only.Return with a application/x-www-form-urlencoded FormData by the specified type
representation of the request body.
sourcefn json<T>(&mut self) -> impl Future<Output = Result<T, PayloadError>> + Sendwhere
T: DeserializeOwned,
Available on crate feature json only.
fn json<T>(&mut self) -> impl Future<Output = Result<T, PayloadError>> + Sendwhere
T: DeserializeOwned,
json only.Return with a JSON by the specified type representation of the request body.
sourcefn multipart(
&mut self,
) -> impl Future<Output = Result<Multipart, PayloadError>> + Send
Available on crate feature multipart only.
fn multipart( &mut self, ) -> impl Future<Output = Result<Multipart, PayloadError>> + Send
multipart only.Return with a multipart/form-data FormData by the specified type
representation of the request body.
sourcefn state<T>(&self) -> Option<T>
Available on crate feature state only.
fn state<T>(&self) -> Option<T>
state only.Return a shared state by the specified type.
sourcefn set_state<T>(&mut self, t: T) -> Option<T>
Available on crate feature state only.
fn set_state<T>(&mut self, t: T) -> Option<T>
state only.Store a shared state.
Available on crate feature cookie only.
cookie only.Get a wrapper of cookie-jar for managing cookies.
§Errors
Will return CookiesError if getting cookies fails.
Available on crate feature cookie only.
cookie only.Get a cookie by the specified name.
sourcefn params<T>(&self) -> Result<T, ParamsError>where
T: DeserializeOwned,
Available on crate feature params only.
fn params<T>(&self) -> Result<T, ParamsError>where
T: DeserializeOwned,
params only.sourcefn param<T>(&self, name: &str) -> Result<T, ParamsError>
Available on crate feature params only.
fn param<T>(&self, name: &str) -> Result<T, ParamsError>
params only.Get single parameter by name.
§Errors
Will return ParamsError if deserializer the single parameter fails.
sourcefn route_info(&self) -> &Arc<RouteInfo>
Available on crate feature params only.
fn route_info(&self) -> &Arc<RouteInfo>
params only.Get current route.
sourcefn remote_addr(&self) -> Option<&SocketAddr>
fn remote_addr(&self) -> Option<&SocketAddr>
Get remote addr.