From ff843881c5abf638e543bac89c7c94a11f1ab71b Mon Sep 17 00:00:00 2001 From: Tamo Date: Mon, 9 Jan 2023 15:14:11 +0100 Subject: [PATCH] remove the documentation of the query parameter extractor module --- .../src/extractors/query_parameters.rs | 63 +------------------ 1 file changed, 1 insertion(+), 62 deletions(-) diff --git a/meilisearch/src/extractors/query_parameters.rs b/meilisearch/src/extractors/query_parameters.rs index e253ee9fd..ebbceacf8 100644 --- a/meilisearch/src/extractors/query_parameters.rs +++ b/meilisearch/src/extractors/query_parameters.rs @@ -1,4 +1,4 @@ -//! For query parameter extractor documentation, see [`Query`]. +//! A module to parse query parameter with deserr use std::marker::PhantomData; use std::{fmt, ops}; @@ -9,56 +9,6 @@ use actix_web::{FromRequest, HttpRequest}; use deserr::{DeserializeError, DeserializeFromValue}; use meilisearch_types::error::{Code, ErrorCode, ResponseError}; -/// Extract typed information from the request's query. -/// -/// To extract typed data from the URL query string, the inner type `T` must implement the -/// [`DeserializeOwned`] trait. -/// -/// Use [`QueryConfig`] to configure extraction process. -/// -/// # Panics -/// A query string consists of unordered `key=value` pairs, therefore it cannot be decoded into any -/// type which depends upon data ordering (eg. tuples). Trying to do so will result in a panic. -/// -/// # Examples -/// ``` -/// use actix_web::{get, web}; -/// use serde::Deserialize; -/// -/// #[derive(Debug, Deserialize)] -/// pub enum ResponseType { -/// Token, -/// Code -/// } -/// -/// #[derive(Debug, Deserialize)] -/// pub struct AuthRequest { -/// id: u64, -/// response_type: ResponseType, -/// } -/// -/// // Deserialize `AuthRequest` struct from query string. -/// // This handler gets called only if the request's query parameters contain both fields. -/// // A valid request path for this handler would be `/?id=64&response_type=Code"`. -/// #[get("/")] -/// async fn index(info: web::Query) -> String { -/// format!("Authorization request for id={} and type={:?}!", info.id, info.response_type) -/// } -/// -/// // To access the entire underlying query struct, use `.into_inner()`. -/// #[get("/debug1")] -/// async fn debug1(info: web::Query) -> String { -/// dbg!("Authorization object = {:?}", info.into_inner()); -/// "OK".to_string() -/// } -/// -/// // Or use destructuring, which is equivalent to `.into_inner()`. -/// #[get("/debug2")] -/// async fn debug2(web::Query(info): web::Query) -> String { -/// dbg!("Authorization object = {:?}", info); -/// "OK".to_string() -/// } -/// ``` #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)] pub struct QueryParameter(pub T, PhantomData<*const E>); @@ -74,16 +24,6 @@ where T: DeserializeFromValue, E: DeserializeError + ErrorCode + 'static, { - /// Deserialize a `T` from the URL encoded query parameter string. - /// - /// ``` - /// # use std::collections::HashMap; - /// # use actix_web::web::Query; - /// let numbers = Query::>::from_query("one=1&two=2").unwrap(); - /// assert_eq!(numbers.get("one"), Some(&1)); - /// assert_eq!(numbers.get("two"), Some(&2)); - /// assert!(numbers.get("three").is_none()); - /// ``` pub fn from_query(query_str: &str) -> Result { let value = serde_urlencoded::from_str::(query_str) .map_err(|e| ResponseError::from_msg(e.to_string(), Code::BadRequest))?; @@ -115,7 +55,6 @@ impl fmt::Display for QueryParameter { } } -/// See [here](#Examples) for example of usage as an extractor. impl FromRequest for QueryParameter where T: DeserializeFromValue,