pub trait Encode<M> {
// Required method
fn encode<E>(&self, cx: &E::Cx, encoder: E) -> Result<E::Ok, E::Error>
where E: Encoder<Mode = M>;
}
Expand description
Trait governing how types are encoded.
This is typically implemented automatically using the Encode
derive.
§Examples
use musli::Encode;
#[derive(Encode)]
struct MyType {
data: [u8; 128],
}
Implementing manually:
use musli::{Encode, Encoder};
struct MyType {
data: [u8; 128],
}
impl<M> Encode<M> for MyType {
fn encode<E>(&self, cx: &E::Cx, encoder: E) -> Result<E::Ok, E::Error>
where
E: Encoder<Mode = M>,
{
encoder.encode_array(&self.data)
}
}
Required Methods§
Object Safety§
This trait is not object safe.
Implementations on Foreign Types§
source§impl Encode<Binary> for SocketAddrV4
Available on crate feature std
only.
impl Encode<Binary> for SocketAddrV4
Available on crate feature
std
only.source§impl Encode<Binary> for SocketAddrV6
Available on crate feature std
only.
impl Encode<Binary> for SocketAddrV6
Available on crate feature
std
only.source§impl Encode<Text> for SocketAddrV4
Available on crate feature std
only.
impl Encode<Text> for SocketAddrV4
Available on crate feature
std
only.source§impl Encode<Text> for SocketAddrV6
Available on crate feature std
only.
impl Encode<Text> for SocketAddrV6
Available on crate feature
std
only.source§impl<'de, M, K, V, S> Encode<M> for HashMap<K, V, S>
Available on crate features alloc
and std
only.
impl<'de, M, K, V, S> Encode<M> for HashMap<K, V, S>
Available on crate features
alloc
and std
only.source§impl<M> Encode<M> for SocketAddr
Available on crate feature std
only.
impl<M> Encode<M> for SocketAddr
Available on crate feature
std
only.source§impl<M> Encode<M> for OsStrwhere
PlatformTag: Encode<M>,
Available on crate feature std
and (Unix or Windows) and crate feature alloc
only.
impl<M> Encode<M> for OsStrwhere
PlatformTag: Encode<M>,
Available on crate feature
std
and (Unix or Windows) and crate feature alloc
only.source§impl<M> Encode<M> for OsStringwhere
PlatformTag: Encode<M>,
Available on crate feature std
and (Unix or Windows) and crate feature alloc
only.
impl<M> Encode<M> for OsStringwhere
PlatformTag: Encode<M>,
Available on crate feature
std
and (Unix or Windows) and crate feature alloc
only.source§impl<M> Encode<M> for Pathwhere
PlatformTag: Encode<M>,
Available on crate feature std
and (Unix or Windows) and crate feature alloc
only.
impl<M> Encode<M> for Pathwhere
PlatformTag: Encode<M>,
Available on crate feature
std
and (Unix or Windows) and crate feature alloc
only.source§impl<M> Encode<M> for PathBufwhere
PlatformTag: Encode<M>,
Available on crate feature std
and (Unix or Windows) and crate feature alloc
only.
impl<M> Encode<M> for PathBufwhere
PlatformTag: Encode<M>,
Available on crate feature
std
and (Unix or Windows) and crate feature alloc
only.source§impl<M> Encode<M> for NonZeroI16
impl<M> Encode<M> for NonZeroI16
source§impl<M> Encode<M> for NonZeroI32
impl<M> Encode<M> for NonZeroI32
source§impl<M> Encode<M> for NonZeroI64
impl<M> Encode<M> for NonZeroI64
source§impl<M> Encode<M> for NonZeroI128
impl<M> Encode<M> for NonZeroI128
source§impl<M> Encode<M> for NonZeroIsize
impl<M> Encode<M> for NonZeroIsize
source§impl<M> Encode<M> for NonZeroU16
impl<M> Encode<M> for NonZeroU16
source§impl<M> Encode<M> for NonZeroU32
impl<M> Encode<M> for NonZeroU32
source§impl<M> Encode<M> for NonZeroU64
impl<M> Encode<M> for NonZeroU64
source§impl<M> Encode<M> for NonZeroU128
impl<M> Encode<M> for NonZeroU128
source§impl<M> Encode<M> for NonZeroUsize
impl<M> Encode<M> for NonZeroUsize
source§impl<M, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> Encode<M> for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15)
impl<M, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> Encode<M> for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15)
source§impl<M, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> Encode<M> for (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15)
impl<M, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> Encode<M> for (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15)
source§impl<M, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> Encode<M> for (T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15)
impl<M, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> Encode<M> for (T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15)
source§impl<M, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> Encode<M> for (T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15)
impl<M, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> Encode<M> for (T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15)
source§impl<M, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> Encode<M> for (T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15)
impl<M, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> Encode<M> for (T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15)
source§impl<M, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> Encode<M> for (T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15)
impl<M, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> Encode<M> for (T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15)
source§impl<M, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> Encode<M> for (T6, T7, T8, T9, T10, T11, T12, T13, T14, T15)
impl<M, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> Encode<M> for (T6, T7, T8, T9, T10, T11, T12, T13, T14, T15)
source§impl<M, T7, T8, T9, T10, T11, T12, T13, T14, T15> Encode<M> for (T7, T8, T9, T10, T11, T12, T13, T14, T15)
impl<M, T7, T8, T9, T10, T11, T12, T13, T14, T15> Encode<M> for (T7, T8, T9, T10, T11, T12, T13, T14, T15)
source§impl<M, T8, T9, T10, T11, T12, T13, T14, T15> Encode<M> for (T8, T9, T10, T11, T12, T13, T14, T15)
impl<M, T8, T9, T10, T11, T12, T13, T14, T15> Encode<M> for (T8, T9, T10, T11, T12, T13, T14, T15)
source§impl<M, T9, T10, T11, T12, T13, T14, T15> Encode<M> for (T9, T10, T11, T12, T13, T14, T15)
impl<M, T9, T10, T11, T12, T13, T14, T15> Encode<M> for (T9, T10, T11, T12, T13, T14, T15)
source§impl<M, T10, T11, T12, T13, T14, T15> Encode<M> for (T10, T11, T12, T13, T14, T15)
impl<M, T10, T11, T12, T13, T14, T15> Encode<M> for (T10, T11, T12, T13, T14, T15)
source§impl<M, T11, T12, T13, T14, T15> Encode<M> for (T11, T12, T13, T14, T15)
impl<M, T11, T12, T13, T14, T15> Encode<M> for (T11, T12, T13, T14, T15)
source§impl<M, T12, T13, T14, T15> Encode<M> for (T12, T13, T14, T15)
impl<M, T12, T13, T14, T15> Encode<M> for (T12, T13, T14, T15)
source§impl<M, T13, T14, T15> Encode<M> for (T13, T14, T15)
impl<M, T13, T14, T15> Encode<M> for (T13, T14, T15)
source§impl<M, T14, T15> Encode<M> for (T14, T15)
impl<M, T14, T15> Encode<M> for (T14, T15)
source§impl<M, T> Encode<M> for BinaryHeap<T>where
T: Encode<M>,
Available on crate feature alloc
only.
impl<M, T> Encode<M> for BinaryHeap<T>where
T: Encode<M>,
Available on crate feature
alloc
only.source§impl<M, T> Encode<M> for BTreeSet<T>where
T: Encode<M>,
Available on crate feature alloc
only.
impl<M, T> Encode<M> for BTreeSet<T>where
T: Encode<M>,
Available on crate feature
alloc
only.source§impl<M, T> Encode<M> for VecDeque<T>where
T: Encode<M>,
Available on crate feature alloc
only.
impl<M, T> Encode<M> for VecDeque<T>where
T: Encode<M>,
Available on crate feature
alloc
only.