pub struct Json<V>(pub V);Expand description
Json extractor to extract data from the request
Tuple Fields§
§0: VImplementations§
Source§impl<T> Json<T>
impl<T> Json<T>
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Returns the inner value
Examples found in repository?
examples/basic.rs (line 100)
96async fn test_handler(
97 query: Option<Query<TestTest>>,
98 json: Json<TestTest>,
99) -> impl Responder<Body = BoxBody> {
100 let json = json.into_inner();
101
102 if let Some(query) = query {
103 let test = query.into_inner();
104
105 assert_eq!(test.username, json.username);
106 assert_eq!(test.password, json.password);
107 }
108
109 format!("Hello, {}!", json.username)
110}Trait Implementations§
Source§impl<V: DeserializeOwned> FromRequest for Json<V>
impl<V: DeserializeOwned> FromRequest for Json<V>
Source§type Error = ServerError
type Error = ServerError
The error that can happen when extracting data
Source§type Future = Ready<Result<Json<V>, <Json<V> as FromRequest>::Error>>
type Future = Ready<Result<Json<V>, <Json<V> as FromRequest>::Error>>
The future that will be used to extract the data
Source§fn from_request(_: &HttpRequest, payload: &mut HttpPayload) -> Self::Future
fn from_request(_: &HttpRequest, payload: &mut HttpPayload) -> Self::Future
Extracts a value of type
Self from the request. The request contains the request body at the moment but that might change in the futureSource§fn extract(req: &HttpRequest) -> Self::Future
fn extract(req: &HttpRequest) -> Self::Future
Extracts a value of type
Self from the requestSource§impl<V: Ord> Ord for Json<V>
impl<V: Ord> Ord for Json<V>
Source§impl<V: PartialOrd> PartialOrd for Json<V>
impl<V: PartialOrd> PartialOrd for Json<V>
impl<V: Eq> Eq for Json<V>
impl<V> StructuralPartialEq for Json<V>
Auto Trait Implementations§
impl<V> Freeze for Json<V>where
V: Freeze,
impl<V> RefUnwindSafe for Json<V>where
V: RefUnwindSafe,
impl<V> Send for Json<V>where
V: Send,
impl<V> Sync for Json<V>where
V: Sync,
impl<V> Unpin for Json<V>where
V: Unpin,
impl<V> UnwindSafe for Json<V>where
V: 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.