flexiber/
lib.rs

1//! # flexiber
2//!
3//! Implementation of the BER-TLV serialization format from ISO 7816-4:2005.
4//!
5//! ITU-T X.690 (08/2015) defines the BER, CER and DER encoding rules for ASN.1
6//!
7//! The exact same document is [ISO/IET 8825-1][iso8825], which is freely available,
8//! inconveniently packed as a single PDF in a ZIP file :)
9//!
10//! ## Credits
11//! This library is a remix of `RustCrypto/utils/der`.
12//!
13//! The core idea taken from `der` is to have `Encodable` require an `encoded_length` method.
14//! By calling this recursively in a first pass, allocations required in other approaches are
15//! avoided.
16//!
17//! [iso8825]: https://standards.iso.org/ittf/PubliclyAvailableStandards/c068345_ISO_IEC_8825-1_2015.zip
18
19#![no_std]
20#![forbid(unsafe_code)]
21// #![warn(missing_docs, rust_2018_idioms)]
22
23#[cfg(feature = "alloc")]
24extern crate alloc;
25
26#[macro_use]
27extern crate delog;
28generate_macros!();
29
30#[cfg(feature = "derive")]
31pub use flexiber_derive::{Decodable, Encodable};
32
33#[cfg(feature = "std")]
34extern crate std;
35
36mod decoder;
37mod encoder;
38mod error;
39mod header;
40mod length;
41mod simpletag;
42mod slice;
43mod tag;
44mod tagged;
45mod traits;
46
47pub use decoder::Decoder;
48pub use encoder::Encoder;
49pub use error::{Error, ErrorKind, Result};
50pub use length::Length;
51pub use simpletag::SimpleTag;
52pub use slice::Slice;
53pub use tag::{Class, Tag, TagLike};
54pub use tagged::{TaggedSlice, TaggedValue};
55#[cfg(feature = "heapless")]
56pub use traits::EncodableHeapless;
57pub use traits::{Container, Decodable, Encodable, Tagged};
58
59// #[derive(Clone, Copy, Debug, Decodable, Encodable, Eq, PartialEq)]
60// struct T2<'a> {
61//     #[tlv(simple = "0x55", slice)]
62//     a: &'a [u8],
63// }