pub struct Query<T>(pub T);Expand description
Extractor for query parameters.
Extracts typed parameters from the query string. The type must implement
serde::Deserialize and be stored in extensions during connection establishment.
§Examples
§Search Parameters
use wsforge::prelude::*;
use serde::Deserialize;
#[derive(Deserialize)]
struct SearchQuery {
q: String,
limit: Option<u32>,
}
async fn search(Query(params): Query<SearchQuery>) -> Result<String> {
let limit = params.limit.unwrap_or(10);
Ok(format!("Searching for '{}' (limit: {})", params.q, limit))
}Tuple Fields§
§0: TTrait Implementations§
Source§impl<T: DeserializeOwned + Send + Sync + Clone + 'static> FromMessage for Query<T>
impl<T: DeserializeOwned + Send + Sync + Clone + 'static> FromMessage for Query<T>
Source§fn from_message<'life0, 'life1, 'life2, 'life3, 'async_trait>(
_message: &'life0 Message,
_conn: &'life1 Connection,
_state: &'life2 AppState,
extensions: &'life3 Extensions,
) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn from_message<'life0, 'life1, 'life2, 'life3, 'async_trait>(
_message: &'life0 Message,
_conn: &'life1 Connection,
_state: &'life2 AppState,
extensions: &'life3 Extensions,
) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Extracts
Self from the message and context. Read moreAuto 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> 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