musli_core/de/as_decoder.rs
1use crate::Context;
2
3use super::Decoder;
4
5/// Trait that allows a type to be repeatedly coerced into a decoder.
6pub trait AsDecoder {
7 /// Context associated with the decoder.
8 type Cx: ?Sized + Context;
9 /// The decoder we reborrow as.
10 type Decoder<'this>: Decoder<
11 'this,
12 Cx = Self::Cx,
13 Error = <Self::Cx as Context>::Error,
14 Mode = <Self::Cx as Context>::Mode,
15 >
16 where
17 Self: 'this;
18
19 /// Borrow self as a new decoder.
20 fn as_decoder(&self) -> Result<Self::Decoder<'_>, <Self::Cx as Context>::Error>;
21}