Trait bincode::de::BorrowDecode
source · [−]pub trait BorrowDecode<'de>: Sized {
fn borrow_decode<D: BorrowDecoder<'de>>(
decoder: &mut D
) -> Result<Self, DecodeError>;
}
Expand description
Trait that makes a type able to be decoded, akin to serde’s Deserialize
trait.
This trait should be implemented for types that contain borrowed data, like &str
and &[u8]
. If your type does not have borrowed data, consider implementing Decode instead.
This trait will be automatically implemented if you enable the derive
feature and add #[derive(bincode::Decode)]
to a type with a lifetime.
Required methods
fn borrow_decode<D: BorrowDecoder<'de>>(
decoder: &mut D
) -> Result<Self, DecodeError>
fn borrow_decode<D: BorrowDecoder<'de>>(
decoder: &mut D
) -> Result<Self, DecodeError>
Attempt to decode this type with the given BorrowDecode.
Implementations on Foreign Types
sourceimpl<'de> BorrowDecode<'de> for &'de Path
impl<'de> BorrowDecode<'de> for &'de Path
fn borrow_decode<D: BorrowDecoder<'de>>(
decoder: &mut D
) -> Result<Self, DecodeError>
sourceimpl<'a, 'de: 'a> BorrowDecode<'de> for &'a [u8]
impl<'a, 'de: 'a> BorrowDecode<'de> for &'a [u8]
fn borrow_decode<D: BorrowDecoder<'de>>(
decoder: &mut D
) -> Result<Self, DecodeError>
sourceimpl<'a, 'de: 'a> BorrowDecode<'de> for Option<&'a [u8]>
impl<'a, 'de: 'a> BorrowDecode<'de> for Option<&'a [u8]>
fn borrow_decode<D: BorrowDecoder<'de>>(
decoder: &mut D
) -> Result<Self, DecodeError>
sourceimpl<'a, 'de: 'a> BorrowDecode<'de> for &'a str
impl<'a, 'de: 'a> BorrowDecode<'de> for &'a str
fn borrow_decode<D: BorrowDecoder<'de>>(
decoder: &mut D
) -> Result<Self, DecodeError>
sourceimpl<'a, 'de: 'a> BorrowDecode<'de> for Option<&'a str>
impl<'a, 'de: 'a> BorrowDecode<'de> for Option<&'a str>
fn borrow_decode<D: BorrowDecoder<'de>>(
decoder: &mut D
) -> Result<Self, DecodeError>
Implementors
impl<'de, T> BorrowDecode<'de> for BorrowCompat<T> where
T: Deserialize<'de>,
This is supported on crate feature
serde
only.