pub struct Into<T, F = Id> { /* private fields */ }Expand description
Adapter to serialize using a From conversion
This adapter works by converting to T and then serializing the converted value using adapter
F.
§Example
use serde::Serialize;
use serde_json::json;
#[derive(Serialize)]
struct Foo(#[serde(with = "serdapt::Into::<u8>")] bool);
let v = serde_json::to_value(Foo(true)).unwrap();
assert_eq!(v, json!(1));Implementations§
Trait Implementations§
Source§impl<T, U, F> SerializeWith<U> for Into<T, F>
impl<T, U, F> SerializeWith<U> for Into<T, F>
Source§fn serialize_with<S: Serializer>(
value: &U,
serializer: S,
) -> Result<S::Ok, S::Error>
fn serialize_with<S: Serializer>( value: &U, serializer: S, ) -> Result<S::Ok, S::Error>
Serializes
value using serializerAuto Trait Implementations§
impl<T, F> Freeze for Into<T, F>
impl<T, F> RefUnwindSafe for Into<T, F>where
F: RefUnwindSafe,
impl<T, F> Send for Into<T, F>where
F: Send,
impl<T, F> Sync for Into<T, F>where
F: Sync,
impl<T, F> Unpin for Into<T, F>where
F: Unpin,
impl<T, F> UnwindSafe for Into<T, F>where
F: 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