Struct pavex::request::query::QueryParams
source · pub struct QueryParams<T>(pub T);
Expand description
Extract (typed) query parameters from the query of an incoming request.
§Guide
Check out the guide for more information on how to use this extractor.
§Example
use pavex::request::query::QueryParams;
// You must derive `serde::Deserialize` for the type you want to extract,
// in this case `Home`.
#[derive(serde::Deserialize)]
pub struct Home {
home_id: u32
}
// The `QueryParams` extractor deserializes the extracted query parameters into
// the type you specified—`Home` in this case.
pub fn get_home(params: &QueryParams<Home>) -> String {
format!("The identifier for this home is: {}", params.0.home_id)
}
The home_id
field will be set to 1
for the ?home_id=1
query string.
Tuple Fields§
§0: T
The extracted query parameters, deserialized into T
, the type you specified.
Implementations§
source§impl<T> QueryParams<T>
impl<T> QueryParams<T>
sourcepub fn extract<'request>(
request_head: &'request RequestHead,
) -> Result<Self, ExtractQueryParamsError>where
T: Deserialize<'request>,
pub fn extract<'request>(
request_head: &'request RequestHead,
) -> Result<Self, ExtractQueryParamsError>where
T: Deserialize<'request>,
The default constructor for QueryParams
.
If the extraction fails, an ExtractQueryParamsError
is returned.
Check out QueryParams
for more information on query parameters.
source§impl QueryParams<()>
impl QueryParams<()>
sourcepub fn register(bp: &mut Blueprint) -> RegisteredConstructor<'_>
pub fn register(bp: &mut Blueprint) -> RegisteredConstructor<'_>
Register the default constructor
for QueryParams
with a Blueprint
.
sourcepub fn default_constructor() -> Constructor
pub fn default_constructor() -> Constructor
The default constructor
and error handler
for QueryParams
.
Auto Trait Implementations§
impl<T> Freeze for QueryParams<T>where
T: Freeze,
impl<T> RefUnwindSafe for QueryParams<T>where
T: RefUnwindSafe,
impl<T> Send for QueryParams<T>where
T: Send,
impl<T> Sync for QueryParams<T>where
T: Sync,
impl<T> Unpin for QueryParams<T>where
T: Unpin,
impl<T> UnwindSafe for QueryParams<T>where
T: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more