unc_account_id/lib.rs
1//! This crate provides a type for representing a syntactically valid, unique account identifier on the [Utility](https://unc.org) network.
2//!
3//! ## Account ID Rules
4//!
5//! - Minimum length is `2`
6//! - Maximum length is `64`
7//! - An **Account ID** consists of **Account ID parts** separated by `.`, example:
8//! - `root` ✔
9//! - `alice.unc` ✔
10//! - `app.stage.testnet` ✔
11//! - Must not start or end with separators (`_`, `-` or `.`):
12//! - `_alice.` ✗
13//! - `.bob.unc-` ✗
14//! - Each part of the **Account ID** consists of lowercase alphanumeric symbols separated either by `_` or `-`, example:
15//! - `ƒelicia.unc` ✗ (`ƒ` is not `f`)
16//! - `1_4m_n0t-al1c3.unc` ✔
17//! - Separators are not permitted to immediately follow each other, example:
18//! - `alice..unc` ✗
19//! - `not-_alice.unc` ✗
20//! - An **Account ID** that is 64 characters long and consists of lowercase hex characters is a specific **implicit account ID**
21//!
22//! Learn more here: <https://docs.unc.org/docs/concepts/account#account-id-rules>
23//!
24//! Also see [Error kind precedence](AccountId#error-kind-precedence).
25//!
26//! ## Usage
27//!
28//! ```
29//! use unc_account_id::{AccountIdRef, AccountId};
30//!
31//! const ALICE: &AccountIdRef = AccountIdRef::new_or_panic("alice.unc");
32//!
33//! let alice: AccountId = "alice.unc".parse().unwrap();
34//!
35//! assert!("ƒelicia.unc".parse::<AccountId>().is_err()); // (ƒ is not f)
36//! ```
37
38mod errors;
39
40mod account_id;
41mod account_id_ref;
42#[cfg(feature = "borsh")]
43mod borsh;
44#[cfg(feature = "serde")]
45mod serde;
46#[cfg(test)]
47mod test_data;
48mod validation;
49
50pub use account_id::AccountId;
51pub use account_id_ref::{AccountIdRef, AccountType};
52pub use errors::{ParseAccountError, ParseErrorKind};