Skip to main content

musli/
en.rs

1//! Traits for generically dealing with an encoding framework.
2//!
3//! The central traits are [Encode] and [Encoder].
4//!
5//! A type implementing [Encode] can use an [Encoder] to encode itself. This
6//! also comes with a derive allowing you to derive high performance encoding
7//! associated with native Rust types.
8//!
9//! ```
10//! use musli::Encode;
11//!
12//! #[derive(Encode)]
13//! pub struct Person<'a> {
14//!     name: &'a str,
15//!     age: u32,
16//! }
17//! ```
18
19/// Derive which automatically implements the [`Encode` trait].
20///
21/// See the [`derives` module] for detailed documentation.
22///
23/// [`derives` module]: crate::_help::derives
24/// [`Encode` trait]: trait@Encode
25///
26/// # Examples
27///
28/// ```
29/// use musli::Encode;
30///
31/// #[derive(Encode)]
32/// struct MyType {
33///     data: [u8; 128],
34/// }
35/// ```
36///
37/// When using through `musli_core`, the crate needs to be specified:
38///
39/// ```
40/// use musli_core::Encode;
41///
42/// #[derive(Encode)]
43/// #[musli(crate = musli_core)]
44/// struct MyType {
45///     data: [u8; 128],
46/// }
47/// ```
48#[doc(inline)]
49pub use musli_core::__macros::Encode;
50
51#[doc(inline)]
52pub use musli_core::en::__traits::{
53    Encode, EncodeBytes, EncodePacked, EncodeTrace, Encoder, EntriesEncoder, EntryEncoder,
54    MapEncoder, SequenceEncoder, TryFastEncode, VariantEncoder,
55};
56
57#[cfg(any(
58    feature = "storage",
59    feature = "wire",
60    feature = "descriptive",
61    feature = "value"
62))]
63pub(crate) use musli_core::en::utils;