pub struct Json<T>(pub T);Expand description
A wrapper type for JSON serialization and deserialization.
This type can be used standalone for convenient JSON operations,
and when the axum feature is enabled, it implements Axum’s
FromRequest and IntoResponse traits.
§Example
use facet::Facet;
use facet_json::Json;
#[derive(Debug, Facet)]
struct User {
name: String,
age: u32,
}
// Wrap a value
let user = Json(User { name: "Alice".to_string(), age: 30 });
// Access the inner value
println!("Name: {}", user.name);Tuple Fields§
§0: TImplementations§
Source§impl<T> Json<T>
impl<T> Json<T>
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Consume the wrapper and return the inner value.
Trait Implementations§
Source§impl<T: Ord> Ord for Json<T>
impl<T: Ord> Ord for Json<T>
Source§impl<T: PartialOrd> PartialOrd for Json<T>
impl<T: PartialOrd> PartialOrd for Json<T>
impl<T: Copy> Copy for Json<T>
impl<T: Eq> Eq for Json<T>
impl<T> StructuralPartialEq for Json<T>
Auto Trait Implementations§
impl<T> Freeze for Json<T>where
T: Freeze,
impl<T> RefUnwindSafe for Json<T>where
T: RefUnwindSafe,
impl<T> Send for Json<T>where
T: Send,
impl<T> Sync for Json<T>where
T: Sync,
impl<T> Unpin for Json<T>where
T: Unpin,
impl<T> UnwindSafe for Json<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