//! # `chanora_state` //! //! Authoritative client-side mirror of server state: server identity, //! channel tree, client list, our own connection state. Owns the //! reducers that fold protocol events into a snapshot, and the //! deltas that the bridge publishes to Flutter view-models //! (per SAD §7.2 and SDD §5). //! //! ## Status //! //! Scaffold only. #![forbid(unsafe_code)] #![warn(missing_docs)] use thiserror::Error; /// Errors raised while reducing protocol events into state or /// producing deltas for the bridge. #[derive(Debug, Error)] pub enum StateError { /// Reducer received an event referencing an unknown entity. #[error("unknown entity: {0}")] Unknown(&'static str), /// A reducer invariant was violated (e.g. two clients claiming /// the same id). #[error("state invariant: {0}")] Invariant(&'static str), } /// Coarse connection lifecycle states surfaced to the bridge. #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum ConnectionState { /// No connection attempt yet, or fully disconnected. Idle, /// Handshake in progress. Connecting, /// Initial state snapshot has been received; ready for use. Ready, /// Connection lost; will not auto-reconnect at this stage. Lost, } #[cfg(test)] mod tests { use super::*; #[test] fn state_transitions_compile() { let _ = ConnectionState::Idle; } }