fernctl/domain/
mod.rs

1//! # Domain Layer — The Core Design Language
2//!
3//! This module contains the pure business logic of the fernctl design system.
4//! It has **zero external dependencies** beyond the standard library and
5//! defines the fundamental types that make up the Fern design language.
6//!
7//! ## Module Organization
8//!
9//! ```text
10//! domain/
11//! ├── tokens/         — Primitive design tokens
12//! │   ├── color       — Type-safe colors with semantic roles
13//! │   ├── spacing     — Scale-based spacing values
14//! │   ├── radius      — Semantic border radius
15//! │   └── typography  — Font families and sizes
16//! │
17//! ├── components/     — Component specifications (future)
18//! │   ├── button      — Button visual spec
19//! │   └── module      — Bar module spec
20//! │
21//! └── theme           — Complete theme combining all tokens
22//! ```
23//!
24//! ## Design Philosophy
25//!
26//! The domain layer embodies several key principles:
27//!
28//! ### 1. Type-Level Correctness
29//!
30//! Invalid states are **unrepresentable**. You cannot create a button with
31//! an invalid radius or assign a foreground color to a background property
32//! — the type system prevents it at compile time.
33//!
34//! ```rust,ignore
35//! // This won't compile — RadiusFull doesn't implement ButtonRadius
36//! let button: ButtonSpec<RadiusFull, ...> = ...;
37//! ```
38//!
39//! ### 2. Zero Runtime Cost
40//!
41//! Marker traits and `PhantomData` exist only at compile time. The runtime
42//! representation of `ColorToken<Surface>` is identical to raw RGB bytes.
43//!
44//! ### 3. Pure and Testable
45//!
46//! No I/O, no side effects, no global state. Every function is deterministic
47//! and can be tested in isolation.
48//!
49//! ## Usage
50//!
51//! Import the prelude for common types:
52//!
53//! ```rust,ignore
54//! use fernctl::domain::prelude::*;
55//!
56//! let surface: ColorToken<Surface> = ColorToken::from_hex("#313244")?;
57//! let spacing = SpacingMd::pixels(); // 12
58//! ```
59
60pub mod theme;
61pub mod tokens;
62pub mod user_config;
63
64// Future modules
65// pub mod components;
66
67/// Convenient re-exports of domain types.
68pub mod prelude {
69    pub use super::theme::Theme;
70    pub use super::tokens::{
71        // Color types
72        ColorToken,
73        BackgroundRole,
74        ForegroundRole,
75        AccentRole,
76        // Color role markers
77        Background,
78        Surface,
79        SurfaceHover,
80        Foreground,
81        ForegroundDim,
82        Accent,
83        // Spacing
84        Spacing,
85        SpacingXs,
86        SpacingSm,
87        SpacingMd,
88        SpacingLg,
89        SpacingXl,
90        // Radius
91        RadiusSemantic,
92        RadiusNone,
93        RadiusSm,
94        RadiusMd,
95        RadiusLg,
96        RadiusFull,
97        // Typography
98        FontFamily,
99    };
100}