1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//! Traits for generically dealing with a decoding framework.
//!
//! The central traits are [Decode] and [Decoder].
//!
//! A type implementing [Decode] can use an [Decoder] to decode an instance of
//! itself. This also comes with a derive allowing you to derive high
//! performance decoding associated with native Rust types.
//!
//! ```rust
//! use musli::Decode;
//!
//! #[derive(Decode)]
//! pub struct Person<'a> {
//!     name: &'a str,
//!     age: u32,
//! }
//! ```

mod decode;
mod decoder;
mod number_visitor;
mod type_hint;
mod value_visitor;

pub use self::decode::Decode;
pub use self::decoder::{
    AsDecoder, Decoder, PackDecoder, PairDecoder, PairsDecoder, SequenceDecoder, VariantDecoder,
};
pub use self::number_visitor::NumberVisitor;
pub use self::type_hint::{LengthHint, NumberHint, TypeHint};
pub use self::value_visitor::ValueVisitor;
use crate::mode::Mode;

/// Decode to a `'static` value.
pub trait DecodeOwned<M>: for<'de> Decode<'de, M>
where
    M: Mode,
{
}

impl<M, D> DecodeOwned<M> for D
where
    D: for<'de> Decode<'de, M>,
    M: Mode,
{
}