pub struct SerdeLite<C>(/* private fields */);Expand description
A wrapper codec that relies on serde_lite. With this, you can wrap serde based codecs that
also work with serde-lite like the [JsonSerdeCodec] or the [MsgpackSerdeCodec].
Only available with the serde_lite feature enabled plus the feature you need for the
wrapped codec.
ยงExample
use codee::{Encoder, Decoder, SerdeLite, string::JsonSerdeCodec, binary::MsgpackSerdeCodec};
use serde_lite::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
struct Test {
s: String,
i: i32,
}
let t = Test {
s: String::from("party time ๐"),
i: 42,
};
let enc = SerdeLite::<JsonSerdeCodec>::encode(&t).unwrap();
let dec: Test = SerdeLite::<JsonSerdeCodec>::decode(&enc).unwrap();
let enc = SerdeLite::<MsgpackSerdeCodec>::encode(&t).unwrap();
let dec: Test = SerdeLite::<MsgpackSerdeCodec>::decode(&enc).unwrap();
assert_eq!(dec, t);Trait Implementationsยง
Auto Trait Implementationsยง
impl<C> Freeze for SerdeLite<C>where
C: Freeze,
impl<C> RefUnwindSafe for SerdeLite<C>where
C: RefUnwindSafe,
impl<C> Send for SerdeLite<C>where
C: Send,
impl<C> Sync for SerdeLite<C>where
C: Sync,
impl<C> Unpin for SerdeLite<C>where
C: Unpin,
impl<C> UnsafeUnpin for SerdeLite<C>where
C: UnsafeUnpin,
impl<C> UnwindSafe for SerdeLite<C>where
C: UnwindSafe,
Blanket Implementationsยง
Sourceยงimpl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Sourceยงtype ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
Sourceยงfn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
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, D> HybridDecoder<T, [u8]> for D
impl<T, D> HybridDecoder<T, [u8]> for D
type Error = <D as Decoder<T>>::Error
fn is_binary_decoder() -> bool
fn decode_bin( val: &[u8], ) -> Result<T, HybridCoderError<<D as HybridDecoder<T, [u8]>>::Error>>
fn decode_str(_val: &str) -> Result<T, HybridCoderError<Self::Error>>
Sourceยงimpl<T, D> HybridDecoder<T, str> for D
impl<T, D> HybridDecoder<T, str> for D
type Error = <D as Decoder<T>>::Error
fn is_binary_decoder() -> bool
fn decode_str( val: &str, ) -> Result<T, HybridCoderError<<D as HybridDecoder<T, str>>::Error>>
fn decode_bin(_val: &[u8]) -> Result<T, HybridCoderError<Self::Error>>
Sourceยงimpl<T, E> HybridEncoder<T, String> for E
impl<T, E> HybridEncoder<T, String> for E
type Error = <E as Encoder<T>>::Error
fn is_binary_encoder() -> bool
fn encode_str( val: &T, ) -> Result<String, HybridCoderError<<E as HybridEncoder<T, String>>::Error>>
fn encode_bin(_val: &T) -> Result<Vec<u8>, HybridCoderError<Self::Error>>
Sourceยงimpl<T, E> HybridEncoder<T, Vec<u8>> for E
impl<T, E> HybridEncoder<T, Vec<u8>> for E
type Error = <E as Encoder<T>>::Error
fn is_binary_encoder() -> bool
fn encode_bin( val: &T, ) -> Result<Vec<u8>, HybridCoderError<<E as HybridEncoder<T, Vec<u8>>>::Error>>
fn encode_str(_val: &T) -> Result<String, HybridCoderError<Self::Error>>
Sourceยงimpl<T> InitializeFromFunction<T> for T
impl<T> InitializeFromFunction<T> for T
Sourceยงfn initialize_from_function(f: fn() -> T) -> T
fn initialize_from_function(f: fn() -> T) -> T
Create an instance of this type from an initialization function
Sourceยงimpl<T> Instrument for T
impl<T> Instrument for T
Sourceยงfn instrument(self, span: Span) -> Instrumented<Self> โ
fn instrument(self, span: Span) -> Instrumented<Self> โ
Sourceยงfn in_current_span(self) -> Instrumented<Self> โ
fn in_current_span(self) -> Instrumented<Self> โ
Sourceยงimpl<T> IntoEither for T
impl<T> IntoEither for T
Sourceยงfn into_either(self, into_left: bool) -> Either<Self, Self> โ
fn into_either(self, into_left: bool) -> Either<Self, Self> โ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSourceยงfn into_either_with<F>(self, into_left: F) -> Either<Self, Self> โ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> โ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSourceยงimpl<T, I> IntoReactiveValue<T, __IntoReactiveValueMarkerBaseCase> for Iwhere
I: Into<T>,
impl<T, I> IntoReactiveValue<T, __IntoReactiveValueMarkerBaseCase> for Iwhere
I: Into<T>,
Sourceยงfn into_reactive_value(self) -> T
fn into_reactive_value(self) -> T
Converts
self into a T.Sourceยงimpl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Sourceยงfn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Returns the layout of the type.
Sourceยงimpl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Sourceยงunsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Returns whether the given value has been niched. Read more
Sourceยงfn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
Writes data to
out indicating that a T is niched.Sourceยงimpl<T> SerializableKey for T
impl<T> SerializableKey for T
Sourceยงimpl<Ret> SpawnIfAsync<(), Ret> for Ret
impl<Ret> SpawnIfAsync<(), Ret> for Ret
Sourceยงimpl<T> StorageAccess<T> for T
impl<T> StorageAccess<T> for T
Sourceยงfn as_borrowed(&self) -> &T
fn as_borrowed(&self) -> &T
Borrows the value.
Sourceยงfn into_taken(self) -> T
fn into_taken(self) -> T
Takes the value.
Sourceยงimpl<T, O> SuperFrom<T> for Owhere
O: From<T>,
impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
Sourceยงfn super_from(input: T) -> O
fn super_from(input: T) -> O
Convert from a type to another type.
Sourceยงimpl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
Sourceยงfn super_into(self) -> O
fn super_into(self) -> O
Convert from a type to another type.