pub mod checkpoint;
pub mod hot;
pub mod ledger;
pub mod trimmer;
pub mod warm;

pub use hot::{HotSignalState, MAX_DECAY_RATES};
pub use ledger::{EntitySignalEntry, NoopWalWriter, SignalLedger, WalWriter};
pub use trimmer::{DEFAULT_MAX_SIGNAL_ENTRIES, trim_cold_entries};
pub use warm::{BucketedCounter, BucketedCounterSnapshot, HOUR_BUCKETS, MINUTE_BUCKETS};

use std::fmt;

/// A signal type index within the schema. Assigned by `SignalLedger` at construction.
///
/// Maximum 64 signal types per entity kind (fits in a `u16`).
/// The value 0 is valid and used for the first registered signal type.
#[derive(
    Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, serde::Serialize, serde::Deserialize,
)]
pub struct SignalTypeId(u16);

impl SignalTypeId {
    #[must_use]
    pub const fn new(id: u16) -> Self {
        Self(id)
    }

    #[must_use]
    pub const fn as_u16(self) -> u16 {
        self.0
    }
}

impl fmt::Display for SignalTypeId {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "{}", self.0)
    }
}
