pub struct Query<T>(pub T);Expand description
Deserializes the URL query string into T via serde_urlencoded.
T must implement serde::Deserialize. Missing required fields or
otherwise malformed query strings fail with 400 Bad Request.
use churust_core::{Churust, Query, TestClient};
use serde::Deserialize;
#[derive(Deserialize)]
struct Pager { page: u32 }
let app = Churust::server()
.routing(|r| {
r.get("/list", |Query(p): Query<Pager>| async move {
format!("page {}", p.page)
});
})
.build();
let res = TestClient::new(app).get("/list?page=3").send().await;
assert_eq!(res.text(), "page 3");Tuple Fields§
§0: TThe deserialized query value.
Trait Implementations§
Source§impl<T> FromCallParts for Query<T>where
T: DeserializeOwned + Send,
impl<T> FromCallParts for Query<T>where
T: DeserializeOwned + Send,
Source§fn from_call_parts<'life0, 'async_trait>(
call: &'life0 mut Call,
) -> Pin<Box<dyn Future<Output = Result<Query<T>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Query<T>: 'async_trait,
fn from_call_parts<'life0, 'async_trait>(
call: &'life0 mut Call,
) -> Pin<Box<dyn Future<Output = Result<Query<T>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Query<T>: 'async_trait,
Build
Self from a mutable borrow of the call, or return an Error
(which the handler renders as the response).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>where
T: Send,
impl<T> Sync for Query<T>where
T: Sync,
impl<T> Unpin for Query<T>where
T: Unpin,
impl<T> UnsafeUnpin for Query<T>where
T: UnsafeUnpin,
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