octseq/lib.rs
1//! Variable length octet sequences.
2//!
3//! This crate provides a set of basic traits that allow defining types that
4//! are generic over a variable length sequence of octets (or, vulgo: bytes).
5//!
6//! There are two groups of traits: those that represent behavior of imutable
7//! octets sequences are collected in the module _[octets]_ and those for
8//! building such sequences are in _[builder]_. Most traits from these modules
9//! are also re-exported at the crate root for convenience.
10//!
11//! These traits are implemented for a number of types. Apart from `[u8]`,
12//! the implementations are opt-in via features. These are:
13//!
14//! * `std` for `Vec<u8>`, `Cow<[u8]>`, and `Arc<[u8]>`,
15//! * `bytes` for the `Bytes` and `BytesMut` types from the
16//! [bytes](https://crates.io/crates/bytes) crate,
17//! * `heapless` for the `Vec<u8, N>` type from the
18//! [heapless](https://crates.io/crates/heapless) crate, and
19//! * `smallvec` for a smallvec for item type `u8` from the
20//! [smallvec](https://crates.io/crates/smallvec) crate.
21//!
22//! A number of additional modules exist that provide a few helpful things:
23//!
24//! * The _[mod@array]_ module provides an octets builder backed by an octets
25//! array.
26//! * The _[mod@str]_ module provides both imutable and buildable string types
27//! that are generic over the octets sequence they wrap.
28//! * The
29#![cfg_attr(feature = "serde", doc = " _[serde]_")]
30#![cfg_attr(not(feature = "serde"), doc = " _serde_")]
31//! module, which needs to be enabled via the `serde`
32//! feature, provides traits and functions to more efficiently serialize
33//! octets sequences.
34
35#![cfg_attr(not(feature = "std"), no_std)]
36#![allow(renamed_and_removed_lints)]
37#![allow(clippy::unknown_clippy_lints)]
38#![cfg_attr(docsrs, feature(doc_cfg))]
39
40pub use self::array::Array;
41pub use self::builder::{
42 EmptyBuilder, FreezeBuilder, FromBuilder, IntoBuilder, OctetsBuilder,
43 ShortBuf, Truncate,
44};
45pub use self::octets::{Octets, OctetsFrom, OctetsInto};
46pub use self::parse::{Parser, ShortInput};
47pub use self::str::{Str, StrBuilder};
48
49pub mod array;
50pub mod builder;
51pub mod octets;
52pub mod parse;
53pub mod serde;
54pub mod str;