strict_encoding/
lib.rs

1// Strict encoding library for deterministic binary serialization.
2//
3// SPDX-License-Identifier: Apache-2.0
4//
5// Designed in 2019-2025 by Dr Maxim Orlovsky <orlovsky@ubideco.org>
6// Written in 2024-2025 by Dr Maxim Orlovsky <orlovsky@ubideco.org>
7//
8// Copyright (C) 2019-2022 LNP/BP Standards Association.
9// Copyright (C) 2022-2025 Laboratories for Ubiquitous Deterministic Computing (UBIDECO),
10//                         Institute for Distributed and Cognitive Systems (InDCS), Switzerland.
11// Copyright (C) 2019-2025 Dr Maxim Orlovsky.
12// All rights under the above copyrights are reserved.
13//
14// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
15// in compliance with the License. You may obtain a copy of the License at
16//
17//        http://www.apache.org/licenses/LICENSE-2.0
18//
19// Unless required by applicable law or agreed to in writing, software distributed under the License
20// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
21// or implied. See the License for the specific language governing permissions and limitations under
22// the License.
23
24#![deny(
25    non_upper_case_globals,
26    non_camel_case_types,
27    non_snake_case,
28    unused_mut,
29    unused_imports,
30    //dead_code,
31    //missing_docs
32)]
33#![cfg_attr(docsrs, feature(doc_auto_cfg))]
34
35#[cfg(feature = "derive")]
36pub use derive::{StrictDecode, StrictDumb, StrictEncode, StrictType};
37#[cfg(not(feature = "derive"))]
38use derive::{StrictDecode, StrictDumb, StrictEncode, StrictType};
39#[cfg(feature = "derive")]
40pub use strict_encoding_derive as derive;
41#[cfg(not(feature = "derive"))]
42use strict_encoding_derive as derive;
43
44#[macro_use]
45extern crate amplify;
46#[cfg(feature = "serde")]
47#[macro_use]
48extern crate serde;
49
50#[macro_use]
51mod macros;
52mod types;
53mod traits;
54#[macro_use]
55mod ident;
56mod error;
57mod reader;
58mod writer;
59mod util;
60mod primitives;
61mod embedded;
62pub mod stl;
63#[cfg(test)]
64pub(crate) mod test;
65
66pub use embedded::{Byte, DecodeRawLe};
67pub use error::{DecodeError, DeserializeError, SerializeError};
68pub use ident::{FieldName, Ident, LibName, TypeName, VariantName, IDENT_MAX_LEN};
69pub use primitives::{NumCls, NumInfo, NumSize, Primitive};
70pub use reader::{ConfinedReader, StreamReader, StrictReader};
71pub use stl::{Bool, InvalidRString, RString, RestrictedCharSet, U1, U2, U3, U4, U5, U6, U7};
72pub use traits::*;
73pub use types::*;
74pub use util::{Sizing, Variant};
75pub use writer::{
76    SplitParent, StreamWriter, StrictParent, StrictWriter, StructWriter, UnionWriter,
77};
78
79#[deprecated(since = "2.2.0", note = "use LIB_EMBEDDED")]
80pub const NO_LIB: &str = LIB_EMBEDDED;
81#[deprecated(since = "2.2.0", note = "use LIB_NAME_STD")]
82pub const STD_LIB: &str = "StdLib";
83pub const LIB_EMBEDDED: &str = "_";
84pub const LIB_NAME_STD: &str = "Std";
85pub const STRICT_TYPES_LIB: &str = "StrictTypes";