musli_core/de/
decode_unsized.rs

1use super::Decoder;
2
3/// A trait implemented for types which can only be decoded by reference.
4///
5/// This is used for types like `str` which are unsized, and might require
6/// internal allocating to properly decode. Simply using the `Decode`
7/// implementation would restrict it to only be used through `&'de str` which
8/// would demand an exact reference to data from the decoded source.
9pub trait DecodeUnsized<'de, M> {
10    /// Decode the given input using a closure as visitor.
11    fn decode_unsized<D, F, O>(cx: &D::Cx, decoder: D, f: F) -> Result<O, D::Error>
12    where
13        D: Decoder<'de, Mode = M>,
14        F: FnOnce(&Self) -> Result<O, D::Error>;
15}