pub struct Query<T>(pub T)
where
T: for<'de> Deserialize<'de> + Send;
Expand description
Represented as url query data
when request with url query, we can using this struct to inject data,
note: the struct must impl serde::Deserialize
and Send
§Example
#[derive(Deserialize, Debug)]
struct Params {
name: String,
zip: String,
}
pub async fn handle(Query(params) : Query<Params>) -> String {
format!("received params: {:?}", params)
}
Tuple Fields§
§0: T
Trait Implementations§
Source§impl<T> FromRequest for Query<T>where
T: for<'de> Deserialize<'de> + Send,
Implements query string extraction for any type that implements Deserialize
impl<T> FromRequest for Query<T>where
T: for<'de> Deserialize<'de> + Send,
Implements query string extraction for any type that implements Deserialize
This implementation allows automatic deserialization of query string parameters into a strongly-typed struct using serde_qs.
type Output<'r> = T
type Error = ParseError
async fn from_request<'r>( req: &'r RequestContext<'_, '_>, _body: OptionReqBody, ) -> Result<Self::Output<'r>, Self::Error>
Auto Trait Implementations§
impl<T> Freeze for Query<T>where
T: Freeze,
impl<T> RefUnwindSafe for Query<T>where
T: RefUnwindSafe,
impl<T> Send for Query<T>
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§
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