musli_core/de/as_decoder.rs
1use crate::{Allocator, 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: Context<Error = Self::Error, Allocator = Self::Allocator>;
9 /// Error associated with decoding.
10 type Error;
11 /// The allocator associated with the decoder.
12 type Allocator: Allocator;
13 /// The mode of the decoder.
14 type Mode: 'static;
15 /// The decoder we reborrow as.
16 type Decoder<'this>: Decoder<
17 'this,
18 Cx = Self::Cx,
19 Error = Self::Error,
20 Allocator = Self::Allocator,
21 Mode = Self::Mode,
22 >
23 where
24 Self: 'this;
25
26 /// Borrow self as a new decoder.
27 fn as_decoder(&self) -> Result<Self::Decoder<'_>, Self::Error>;
28}