pub trait Decode: Sized {
type Error;
// Required method
fn decode(input: &mut Input<'_>) -> Result<Self, Self::Error>;
}
Expand description
Denotes a type capable of being decoded.
This trait can be derived for custom types using the Decode
derive macro.
Do remember that this macro assumes that the Encode
trait has not been manually implemented (i.e. it must either be not implemented or derived).
Breaking this promise is a logic error and can lead to failed decodings.
See also the decode
module’s documentation on how to use decodings.
Required Associated Types§
Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl Decode for Infallible
impl Decode for Infallible
Source§impl Decode for SocketAddr
impl Decode for SocketAddr
Source§impl Decode for CString
Available on crate feature alloc
only.
impl Decode for CString
alloc
only.Source§fn decode(input: &mut Input<'_>) -> Result<Self, Self::Error>
fn decode(input: &mut Input<'_>) -> Result<Self, Self::Error>
Decodes a byte slice from the input.
This implementation will always allocate one more byte than specified by the slice for the null terminator. Note that any null value already in the data will truncate the final string.
type Error = <Vec<u8> as Decode>::Error
Source§impl Decode for PhantomPinned
impl Decode for PhantomPinned
Source§impl Decode for SocketAddrV4
impl Decode for SocketAddrV4
Source§impl Decode for SocketAddrV6
impl Decode for SocketAddrV6
Source§impl Decode for AtomicBool
Available on target_has_atomic="8"
only.
impl Decode for AtomicBool
target_has_atomic="8"
only.Source§impl Decode for AtomicIsize
Available on target_has_atomic="ptr"
only.
impl Decode for AtomicIsize
target_has_atomic="ptr"
only.Source§impl Decode for AtomicUsize
Available on target_has_atomic="ptr"
only.
impl Decode for AtomicUsize
target_has_atomic="ptr"
only.Source§impl Decode for SystemTime
Available on crate feature std
only.
impl Decode for SystemTime
std
only.Source§impl<K, S> Decode for HashSet<K, S>
Available on crate feature std
only.
impl<K, S> Decode for HashSet<K, S>
std
only.type Error = CollectionDecodeError<Infallible, ItemDecodeError<usize, <K as Decode>::Error>>
fn decode(input: &mut Input<'_>) -> Result<Self, Self::Error>
Source§impl<K, V, S, E> Decode for HashMap<K, V, S>
Available on crate feature std
only.
impl<K, V, S, E> Decode for HashMap<K, V, S>
std
only.type Error = CollectionDecodeError<Infallible, ItemDecodeError<usize, E>>
fn decode(input: &mut Input<'_>) -> Result<Self, Self::Error>
Source§impl<T> Decode for PhantomData<T>
impl<T> Decode for PhantomData<T>
Source§impl<T: Decode> Decode for (T₁, T₂, …, Tₙ)
Implemented for tuples with up to twelve members.
impl<T: Decode> Decode for (T₁, T₂, …, Tₙ)
Implemented for tuples with up to twelve members.
Source§impl<T: Decode> Decode for LinkedList<T>
Available on crate feature alloc
only.
impl<T: Decode> Decode for LinkedList<T>
alloc
only.type Error = CollectionDecodeError<Infallible, ItemDecodeError<usize, <T as Decode>::Error>>
fn decode(input: &mut Input<'_>) -> Result<Self, Self::Error>
Source§impl<T: Decode> Decode for Arc<T>
Available on crate feature alloc
and target_has_atomic="ptr"
only.
impl<T: Decode> Decode for Arc<T>
alloc
and target_has_atomic="ptr"
only.Source§impl<T: Decode> Decode for Weak<T>
Available on crate feature alloc
and target_has_atomic="ptr"
only.
impl<T: Decode> Decode for Weak<T>
alloc
and target_has_atomic="ptr"
only.Source§impl<T: Decode> Decode for Vec<T>
Available on crate feature alloc
only.
impl<T: Decode> Decode for Vec<T>
alloc
only.