pub struct Query<T>(_);
Expand description
Extract typed information from from the request’s query.
Example
#[macro_use] extern crate serde_derive;
use actix_web::{App, Query, http};
#[derive(Debug, Deserialize)]
pub enum ResponseType {
Token,
Code
}
#[derive(Deserialize)]
pub struct AuthRequest {
id: u64,
response_type: ResponseType,
}
// use `with` extractor for query info
// this handler get called only if request's query contains `username` field
// The correct request for this handler would be `/index.html?id=64&response_type=Code"`
fn index(info: Query<AuthRequest>) -> String {
format!("Authorization request for client with id={} and type={:?}!", info.id, info.response_type)
}
fn main() {
let app = App::new().resource(
"/index.html",
|r| r.method(http::Method::GET).with(index)); // <- use `with` extractor
}
Implementations
sourceimpl<T> Query<T>
impl<T> Query<T>
sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Deconstruct to a inner value
Trait Implementations
sourceimpl<T, S> FromRequest<S> for Query<T>where
T: DeserializeOwned,
impl<T, S> FromRequest<S> for Query<T>where
T: DeserializeOwned,
type Config = QueryConfig<S>
type Config = QueryConfig<S>
Configuration for conversion process
sourcefn from_request(req: &HttpRequest<S>, cfg: &Self::Config) -> Self::Result
fn from_request(req: &HttpRequest<S>, cfg: &Self::Config) -> Self::Result
Convert request to a Self
sourcefn extract(req: &HttpRequest<S>) -> Self::Result
fn extract(req: &HttpRequest<S>) -> Self::Result
Convert request to a Self Read more
sourceimpl<T: Ord> Ord for Query<T>
impl<T: Ord> Ord for Query<T>
1.21.0 · sourcefn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl<T: PartialEq> PartialEq<Query<T>> for Query<T>
impl<T: PartialEq> PartialEq<Query<T>> for Query<T>
sourceimpl<T: PartialOrd> PartialOrd<Query<T>> for Query<T>
impl<T: PartialOrd> PartialOrd<Query<T>> for Query<T>
sourcefn partial_cmp(&self, other: &Query<T>) -> Option<Ordering>
fn partial_cmp(&self, other: &Query<T>) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl<T: Eq> Eq for Query<T>
impl<T> StructuralEq for Query<T>
impl<T> StructuralPartialEq for Query<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for Query<T>where
T: RefUnwindSafe,
impl<T> Send for Query<T>where
T: Send,
impl<T> Sync for Query<T>where
T: Sync,
impl<T> Unpin for Query<T>where
T: Unpin,
impl<T> UnwindSafe for Query<T>where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.