apimock_config/lib.rs
1//! Configuration model for apimock.
2//!
3//! # Responsibilities
4//!
5//! - Read `apimock.toml` and every file it references.
6//! - Resolve relative paths against the config file's parent directory.
7//! - Validate that paths exist, rules are consistent, etc.
8//! - Provide the [`Workspace`] façade that a GUI uses to edit a
9//! loaded configuration by domain-level commands instead of TOML
10//! text.
11//!
12//! # What is deliberately *not* here
13//!
14//! - Compiling Rhai middlewares — that's `apimock-server`'s job. This
15//! crate only records the paths listed under `service.middlewares`.
16//! - HTTP response construction. Fully in `apimock-server`.
17//! - Rule-set parsing. Delegated to `apimock-routing::RuleSet::new`.
18//!
19//! # 5.1.0 — GUI-facing API
20//!
21//! 5.0.0 defined the *shape* of the types a future GUI would depend
22//! on; 5.1 makes the `Workspace` value that wraps them actually
23//! loadable and introspectable. Per the spec's §12 step plan, 5.1.0
24//! implements Steps 1–3 (load + snapshot + validate), leaving Step 4
25//! (save + diff) and Step 5 (richer routing snapshot) for 5.2+.
26
27pub mod config;
28pub mod error;
29pub mod path_util;
30mod toml_writer;
31pub mod view;
32pub mod workspace;
33
34pub use config::{
35 Config,
36 constant::{LISTENER_DEFAULT_IP_ADDRESS, LISTENER_DEFAULT_PORT},
37 listener_config::ListenerConfig,
38 log_config::LogConfig,
39 service_config::ServiceConfig,
40};
41pub use error::{ApplyError, ConfigError, ConfigResult, SaveError, WorkspaceError};
42pub use view::{
43 ApplyResult, ConfigFileKind, ConfigFileView, ConfigNodeView, DiffItem, DiffKind, Diagnostic,
44 EditCommand, EditValue, NodeId, NodeKind, NodeValidation, ReloadHint, RespondPayload,
45 RootSettingKey, RulePayload, SaveResult, Severity, ValidationIssue, ValidationReport,
46 WorkspaceSnapshot,
47};
48pub use workspace::Workspace;