1#![warn(clippy::unwrap_used)]
2
3pub mod enc;
4pub mod error;
5pub mod fuid;
6pub mod id64;
7pub mod key_part;
8pub mod key_type;
9pub mod num_ops;
10pub mod record_status;
11pub mod zbase;
12
13#[cfg(feature = "std")]
14pub mod persist;
15
16#[cfg(feature = "deserialize")]
17pub mod deserialize;
18
19#[cfg(feature = "dyn-value")]
20pub mod dyn_value;
21
22use arrayvec::ArrayString;
23
24pub use armour_derive::*;
25pub use armour_typ::{
26 EnumType, Fields, GetType, ScalarTyp, SchemaFields, SchemaTyp, SimpleEnumType, StructType, Typ,
27};
28pub use error::ArmourError;
29pub use fuid::{Fuid, OptFuid};
30pub use id64::{Id64, OptId64};
31pub use key_type::{KeyScheme, KeyType};
32
33pub mod dyn_types {
35 pub use armour_typ::get_type;
36 pub use armour_typ::{EnumType, Fields, SimpleEnumType, StructType, Typ};
37}
38
39pub type IdStr = ArrayString<13>;
40
41pub type Result<T, E = ArmourError> = core::result::Result<T, E>;
42
43pub const ID_ENC_FLAG: u64 = 1u64 << 8;
44
45#[macro_export]
51macro_rules! const_hasher {
52 ($m_name: ident, $key_name: literal) => {
53 pub mod $m_name {
54 use $crate::enc::{Cipher, IdHasher};
55
56 #[derive(Debug, PartialOrd, Ord, PartialEq, Eq, Clone, Copy, Hash)]
57 pub struct Hasher;
58
59 impl IdHasher for Hasher {
60 const HASHER: Cipher = Cipher::new(env!(concat!("APP_ID_KEY_", $key_name)));
61 }
62 }
63 };
64}
65
66#[macro_export]
72macro_rules! const_hasher_or {
73 ($m_name:ident, $key_name:literal, $default:literal) => {
74 pub mod $m_name {
75 use $crate::enc::{Cipher, IdHasher};
76
77 #[derive(Debug, PartialOrd, Ord, PartialEq, Eq, Clone, Copy, Hash)]
78 pub struct Hasher;
79
80 impl IdHasher for Hasher {
81 const HASHER: Cipher = Cipher::new({
82 #[cfg(debug_assertions)]
83 {
84 match option_env!(concat!("APP_ID_KEY_", $key_name)) {
85 Some(v) => v,
86 None => $default,
87 }
88 }
89 #[cfg(not(debug_assertions))]
90 {
91 env!(concat!("APP_ID_KEY_", $key_name))
92 }
93 });
94 }
95 }
96 };
97}
98
99#[macro_export]
103macro_rules! hasher {
104 ($m_name: ident, $key: literal) => {
105 pub mod $m_name {
106 use $crate::enc::{Cipher, IdHasher};
107
108 #[derive(Debug, PartialOrd, Ord, PartialEq, Eq, Clone, Copy, Hash)]
109 pub struct Hasher;
110
111 impl IdHasher for Hasher {
112 const HASHER: Cipher = Cipher::new($key);
113 }
114 }
115 };
116}