Skip to main content

musli_core/de/
mod.rs

1//! Traits for generically dealing with a decoding framework.
2//!
3//! The central traits are [Decode] and [Decoder].
4//!
5//! A type implementing [Decode] can use an [Decoder] to decode an instance of
6//! itself. This also comes with a derive allowing you to derive high
7//! performance decoding associated with native Rust types.
8//!
9//! The derive in this module generates code which refers to `musli_core`, so a
10//! crate which depends on `musli_core` alone can use it without a
11//! `#[musli(crate = ..)]` attribute. If the dependency is renamed in
12//! `Cargo.toml`, point the derive at the new name with
13//! `#[musli(crate = <name>)]`.
14//!
15//! # Examples
16//!
17//! ```
18//! use musli_core::Decode;
19//!
20//! #[derive(Decode)]
21//! pub struct Person<'a> {
22//!     name: &'a str,
23//!     age: u32,
24//! }
25//! ```
26
27/// Derive which automatically implements the [`Decode` trait].
28///
29/// See the [`derives` module] for detailed documentation.
30///
31/// [`derives` module]: <https://docs.rs/musli/latest/musli/_help/derives/index.html>
32/// [`Decode` trait]: <https://docs.rs/musli/latest/musli/trait.Decode.html>
33///
34/// # Examples
35///
36/// ```
37/// use musli_core::Decode;
38///
39/// #[derive(Decode)]
40/// struct MyType {
41///     data: [u8; 128],
42/// }
43/// ```
44///
45/// A crate which renames `musli_core`, such as with `musli_core01 = { package =
46/// "musli-core", .. }` in `Cargo.toml`, has to name it with `#[musli(crate =
47/// musli_core01)]`.
48#[doc(inline)]
49pub use musli_macros::MusliCoreDecode as Decode;
50
51#[doc(inline)]
52pub use self::__traits::*;
53
54mod as_decoder;
55mod decode;
56mod decode_bytes;
57mod decode_owned;
58mod decode_packed;
59mod decode_slice_builder;
60mod decode_trace;
61mod decode_unsized;
62mod decode_unsized_bytes;
63mod decoder;
64mod entries_decoder;
65mod entry_decoder;
66mod map_decoder;
67mod sequence_decoder;
68mod size_hint;
69mod skip;
70mod unsized_visitor;
71mod variant_decoder;
72mod visitor;
73
74#[doc(hidden)]
75pub mod __traits {
76    pub use super::as_decoder::AsDecoder;
77    pub use super::decode::Decode;
78    pub use super::decode_bytes::DecodeBytes;
79    pub use super::decode_owned::DecodeOwned;
80    pub use super::decode_packed::DecodePacked;
81    pub use super::decode_slice_builder::DecodeSliceBuilder;
82    pub use super::decode_trace::DecodeTrace;
83    pub use super::decode_unsized::DecodeUnsized;
84    pub use super::decode_unsized_bytes::DecodeUnsizedBytes;
85    pub use super::decoder::{Decoder, TryFastDecode};
86    pub use super::entries_decoder::EntriesDecoder;
87    pub use super::entry_decoder::EntryDecoder;
88    pub use super::map_decoder::MapDecoder;
89    pub use super::sequence_decoder::SequenceDecoder;
90    pub use super::size_hint::SizeHint;
91    pub use super::skip::Skip;
92    pub use super::unsized_visitor::UnsizedVisitor;
93    pub use super::variant_decoder::VariantDecoder;
94    pub use super::visitor::Visitor;
95}
96
97#[doc(hidden)]
98pub mod utils;