Struct SerdeLite

Source
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> UnwindSafe for SerdeLite<C>
where C: UnwindSafe,

Blanket Implementationsยง

Sourceยง

impl<T> Any for T
where T: 'static + ?Sized,

Sourceยง

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Sourceยง

impl<T> ArchivePointee for T

Sourceยง

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Sourceยง

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
Sourceยง

impl<T> Borrow<T> for T
where T: ?Sized,

Sourceยง

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Sourceยง

impl<T> BorrowMut<T> for T
where T: ?Sized,

Sourceยง

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Sourceยง

impl<T> From<T> for T

Sourceยง

fn from(t: T) -> T

Returns the argument unchanged.

Sourceยง

impl<T, D> HybridDecoder<T, [u8]> for D
where D: Decoder<T, Encoded = [u8]>,

Sourceยง

impl<T, D> HybridDecoder<T, str> for D
where D: Decoder<T, Encoded = str>,

Sourceยง

impl<T, E> HybridEncoder<T, String> for E
where E: Encoder<T, Encoded = String>,

Sourceยง

impl<T, E> HybridEncoder<T, Vec<u8>> for E
where E: Encoder<T, Encoded = Vec<u8>>,

Sourceยง

impl<T, U> Into<U> for T
where U: From<T>,

Sourceยง

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Sourceยง

impl<T> LayoutRaw for T

Sourceยง

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
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

Sourceยง

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>>)

Writes data to out indicating that a T is niched.
Sourceยง

impl<T> Pointee for T

Sourceยง

type Metadata = ()

The metadata type for pointers and references to this type.
Sourceยง

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Sourceยง

type Error = Infallible

The type returned in the event of a conversion error.
Sourceยง

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Sourceยง

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Sourceยง

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Sourceยง

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.