#![cfg_attr(not(feature = "std"), no_std)]
#[cfg_attr(not(feature = "std"), macro_use)]
#[cfg(not(feature = "std"))]
extern crate alloc;

pub use armour_derive::*;

pub use collections::cid::{bytes_unsafe, Cid};
pub use collections::entry::Entry;
pub use collections::id::{Id, RecordStatus};
pub use collections::record::Record;
pub use datetime::{Datetime, Duration};
pub use dyn_types::{
    get_type::GetType,
    key_type::{GetKeyType, KeyBytes, KeyType},
    value::Value,
    Typ,
};

pub mod collections;
pub mod datetime;
pub mod dyn_types;

#[macro_export]
macro_rules! bf_hasher {
    ($m_name: ident, $name: ident, $key: expr) => {
        pub mod $m_name {
            use armour::{
                collections::ident::{IdHasher, ID},
                Id,
            };
            use blowfish::BlowfishLE;
            use once_cell::sync::Lazy;

            static BF: once_cell::sync::Lazy<BlowfishLE> =
                Lazy::new(|| armour::collections::ident::create_bf($key));

            #[derive(Debug, PartialOrd, Ord, PartialEq, Eq, Clone, Copy, Default)]
            pub struct Hasher;

            impl IdHasher for Hasher {
                #[inline]
                fn get_hasher() -> &'static BlowfishLE {
                    Lazy::force(&BF)
                }

                fn get_name() -> &'static str {
                    stringify!($name)
                }
            }

            pub type $name = ID<Hasher>;
            pub type Ident = Id<Hasher>;
        }
    };
}
