musli_core::de

Trait DecodeUnsized

Source
pub trait DecodeUnsized<'de, M> {
    // Required method
    fn decode_unsized<D, F, O>(
        cx: &D::Cx,
        decoder: D,
        f: F,
    ) -> Result<O, D::Error>
       where D: Decoder<'de, Mode = M>,
             F: FnOnce(&Self) -> Result<O, D::Error>;
}
Expand description

A trait implemented for types which can only be decoded by reference.

This is used for types like str which are unsized, and might require internal allocating to properly decode. Simply using the Decode implementation would restrict it to only be used through &'de str which would demand an exact reference to data from the decoded source.

Required Methods§

Source

fn decode_unsized<D, F, O>(cx: &D::Cx, decoder: D, f: F) -> Result<O, D::Error>
where D: Decoder<'de, Mode = M>, F: FnOnce(&Self) -> Result<O, D::Error>,

Decode the given input using a closure as visitor.

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<'de, M> DecodeUnsized<'de, M> for str

Source§

fn decode_unsized<D, F, O>(_: &D::Cx, decoder: D, f: F) -> Result<O, D::Error>
where D: Decoder<'de>, F: FnOnce(&Self) -> Result<O, D::Error>,

Source§

impl<'de, M> DecodeUnsized<'de, M> for CStr

Source§

fn decode_unsized<D, F, O>(cx: &D::Cx, decoder: D, f: F) -> Result<O, D::Error>
where D: Decoder<'de, Mode = M>, F: FnOnce(&Self) -> Result<O, D::Error>,

Implementors§