//! Events service — public API for the events domain. //! //! This module re-exports the pure buffer types from `buffer.rs` and the //! side-effectful watcher subscription from `io.rs`. HTTP handlers call //! these exports instead of containing the logic inline. //! //! Conventions: `docs/architecture/service-modules.md` pub mod buffer; pub(super) mod io; pub use buffer::{EventBuffer, StoredEvent}; // Re-exported for tests (http::events uses it via `use super::*`). #[allow(unused_imports)] pub use buffer::MAX_BUFFER_SIZE; pub use io::subscribe_to_watcher; // ── Error type ──────────────────────────────────────────────────────────────── /// Typed errors returned by `service::events` functions. /// /// Events operations on the in-memory buffer are infallible; this enum /// exists to satisfy the module convention and to accommodate future /// error cases (e.g. persistence). #[allow(dead_code)] #[derive(Debug)] pub enum Error { /// A serialisation or internal error occurred. Internal(String), } impl std::fmt::Display for Error { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { Self::Internal(msg) => write!(f, "Events error: {msg}"), } } } // ── Public API ──────────────────────────────────────────────────────────────── /// Return all events in `buffer` recorded after `since_ms` milliseconds. pub fn events_since(buffer: &EventBuffer, since_ms: u64) -> Vec { buffer.events_since(since_ms) }