Skip to main content

canic_core/domain/
state.rs

1//! Module: domain::state
2//!
3//! Responsibility: define pure state-domain value enums shared by stable
4//! records, storage ops, and boundary DTOs.
5//! Does not own: stable records, state mutation, DTO structs, or workflow
6//! orchestration.
7//! Boundary: storage and DTO modules re-export these values to preserve public
8//! API paths while internal code imports the domain owner where practical.
9
10use candid::CandidType;
11use serde::{Deserialize, Serialize};
12use std::fmt::{self, Display};
13
14///
15/// AppMode
16///
17
18#[derive(CandidType, Clone, Copy, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
19pub enum AppMode {
20    #[default]
21    Enabled,
22    Readonly,
23    Disabled,
24}
25
26impl Display for AppMode {
27    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
28        let label = match self {
29            Self::Enabled => "Enabled",
30            Self::Readonly => "Readonly",
31            Self::Disabled => "Disabled",
32        };
33
34        f.write_str(label)
35    }
36}
37
38///
39/// AppStatus
40///
41
42#[derive(CandidType, Clone, Copy, Debug, Deserialize, Eq, PartialEq)]
43pub enum AppStatus {
44    Active,
45    Readonly,
46    Stopped,
47}