Skip to main content

deser_core/
lib.rs

1//! The core of [deser](https://docs.rs/deser).
2//!
3//! This crate is an implementation detail of deser, use the
4//! [`deser`](https://docs.rs/deser) crate instead which re-exports
5//! everything in here together with the derive macros.  The crates of the
6//! data formats depend on this crate so that they can be compiled without
7//! waiting for the derive macros.
8#![doc(html_logo_url = "https://raw.githubusercontent.com/mitsuhiko/deser/main/artwork/logo.svg")]
9#![cfg_attr(docsrs, feature(doc_cfg))]
10#![cfg_attr(not(any(feature = "std", test)), no_std)]
11
12extern crate alloc;
13
14#[macro_use]
15mod macros;
16mod event;
17
18pub mod adapters;
19pub mod de;
20mod error;
21pub mod ext;
22pub mod hints;
23#[cfg(feature = "io")]
24pub mod io;
25pub mod ser;
26pub mod stream;
27
28mod bytes_format;
29mod extensions;
30mod foreign_impls;
31mod position;
32mod source;
33mod state;
34mod std_impls;
35#[cfg(feature = "std")]
36mod std_only_impls;
37mod sync;
38mod text;
39
40pub use self::bytes_format::BytesFormat;
41pub use self::error::{Error, ErrorAttachment, ErrorContext, ErrorKind};
42pub use self::event::{Atom, Bytes, ContainerShape, Event, Implicit, ImplicitValue, Order};
43pub use self::extensions::EventData;
44pub use self::position::Position;
45pub use self::source::Source;
46pub use self::state::State;
47pub use self::text::Text;
48
49// common re-exports
50
51#[doc(no_inline)]
52pub use self::{de::Deserialize, ser::Serialize, stream::Streamed};
53
54#[cfg(feature = "derive")]
55pub mod derive;
56
57// Helpers for writing formats (float formatting, small copies).  Not
58// public API.
59#[doc(hidden)]
60#[path = "format.rs"]
61pub mod __format;
62
63// Everything the code generated by the derive refers to.  Not public API.
64// Standard library items are re-exported so that the generated code does
65// not depend on what the names refer to where the derive is used.
66#[cfg(feature = "derive")]
67#[doc(hidden)]
68pub mod __derive {
69    pub use alloc::borrow::Cow;
70    pub use alloc::boxed::Box;
71    pub use alloc::string::String;
72    pub use alloc::vec::Vec;
73    pub use core::convert::Into;
74    pub use core::default::Default;
75    pub use core::marker::{PhantomData, Send, Sync};
76    pub use core::mem::replace;
77    pub use core::option::Option::{self, None, Some};
78    pub use core::primitive::{str, u8};
79    pub use core::result::Result::{Err, Ok};
80    pub use core::unreachable;
81    pub type Result<T> = core::result::Result<T, super::Error>;
82    pub type StrCow<'a> = Cow<'a, str>;
83
84    pub use crate::adapters::ser_impls::SerializeAsRef;
85    pub use crate::adapters::{DerivedDeserialize, DerivedSerialize};
86    pub use crate::de::atoms::{
87        atom_into, atom_into_handle, borrowed_atom_into, borrowed_atom_into_handle, field_update,
88        unit_struct,
89    };
90    pub use crate::de::enums::{
91        AdjacentlyTaggedSink, BoxedVariant, EnumKey, ExternallyTaggedSink, IgnoredContent,
92        IgnoredVariant, InternallyTaggedSink, OtherVariant, Tag, UnitEnum, UntaggedTry, Variant,
93        VariantMaker, Variants, atom_sink, unit_enum_atom_into, unit_enum_sink, untagged_atom,
94        untagged_borrowed_atom, untagged_fallback, untagged_handle,
95    };
96    pub use crate::de::fields::{
97        Collect, FieldKeySink, FieldSlot, NextField, Slot, StructFields, StructFinish, StructInfo,
98        StructSink, StructUpdateSink, UpdateFields, collected_errors, missing_field,
99        new_missing_field_error, no_field_slot,
100    };
101    pub use crate::de::mapped::mapped;
102    pub use crate::de::recording::RecordBuf;
103    pub use crate::de::unknown::{unclaimed_keys, unknown_field};
104    pub use crate::de::update::UpdateTarget;
105    pub use crate::error::unknown_variant;
106    pub use crate::ser::begin::{
107        Begin, FIELDS_END, IndexedSeq, IndexedSeqEmitter, IndexedStruct, IndexedStructEmitter,
108        PlainSink, StructField, describe_struct, emit_plain_field, serialize_indexed,
109    };
110    pub use crate::ser::enums::{
111        EntrySer, FieldSer, FieldsSer, FlatFieldsSer, SeqSer, TaggedContent, TaggedNewtype,
112        UnitName, UnitVariants, begin_unit, describe_unit, serialize_unit, skipped_variant,
113    };
114    pub use crate::ser::flatten::FlattenedStruct;
115}