pub struct Config {
pub modules_path: Option<PathBuf>,
pub executor: ExecutorConfig,
pub observability: ObservabilityConfig,
pub user_namespaces: HashMap<String, Value>,
pub yaml_path: Option<PathBuf>,
pub mode: ConfigMode,
}Expand description
Top-level apcore configuration (PROTOCOL_SPEC §9.1).
Canonical wire format is a nested JSON/YAML object with executor,
observability, and any user-defined namespaces as siblings:
modules_path: ./modules
executor:
max_call_depth: 32
default_timeout: 30000
observability:
tracing:
enabled: true
my_vendor:
custom_setting: foov0.18.0 BREAKING CHANGE. Prior versions accepted root-level
max_call_depth, default_timeout_ms, etc. The custom Deserialize impl
now rejects these with a hard error pointing at MIGRATION-v0.18.md.
Fields§
§modules_path: Option<PathBuf>§executor: ExecutorConfig§observability: ObservabilityConfig§user_namespaces: HashMap<String, Value>User-defined and vendor namespaces. Captures any top-level key not
matching a canonical namespace above. Per spec §9.1, custom namespace
names should follow [a-z][a-z0-9-]*.
yaml_path: Option<PathBuf>§mode: ConfigModeImplementations§
Source§impl Config
impl Config
Sourcepub fn from_json_file(path: &Path) -> Result<Self, ModuleError>
pub fn from_json_file(path: &Path) -> Result<Self, ModuleError>
Load config from a JSON file, apply env overrides, and validate.
Sourcepub fn from_yaml_file(path: &Path) -> Result<Self, ModuleError>
pub fn from_yaml_file(path: &Path) -> Result<Self, ModuleError>
Load config from a YAML file, apply env overrides, and validate.
Sourcepub fn load(path: &Path) -> Result<Self, ModuleError>
pub fn load(path: &Path) -> Result<Self, ModuleError>
Auto-detect format by file extension and load.
Sourcepub fn validate(&self) -> Result<(), ModuleError>
pub fn validate(&self) -> Result<(), ModuleError>
Validate config constraints. Returns an error listing all violations.
Sourcepub fn from_defaults() -> Self
pub fn from_defaults() -> Self
Build config from defaults, applying env var overrides.
Sourcepub fn discover() -> Result<Self, ModuleError>
pub fn discover() -> Result<Self, ModuleError>
Discover and load config using the §9.14 search order.
If no file is found, returns Config::from_defaults().
Sourcepub fn get(&self, key: &str) -> Option<Value>
pub fn get(&self, key: &str) -> Option<Value>
Get a config value by dot-path key.
Walks the canonical nested namespace tree (executor.*,
observability.*, modules_path) and falls back to user-defined
namespaces. Per spec §9.1, all keys MUST use the canonical
<namespace>.<field> form. Legacy v0.17.x short-form aliases
(e.g. bare max_call_depth) are NOT accepted.
Sourcepub fn set(&mut self, key: &str, value: Value)
pub fn set(&mut self, key: &str, value: Value)
Set a config value by dot-path key.
Attempts to set canonical typed fields first, then falls back to user namespaces. Returns silently on type mismatch.
Sourcepub fn reload(&mut self) -> Result<(), ModuleError>
pub fn reload(&mut self) -> Result<(), ModuleError>
Reload config from the stored yaml_path. Returns error if no path stored.
Sourcepub fn data(&self) -> Value
pub fn data(&self) -> Value
Return a serde_json::Value representing the full config as the
canonical nested JSON object (PROTOCOL_SPEC §9.1 wire format).
pub fn register_namespace(reg: NamespaceRegistration) -> Result<(), ModuleError>
Sourcepub fn env_map(mapping: HashMap<String, String>) -> Result<(), ModuleError>
pub fn env_map(mapping: HashMap<String, String>) -> Result<(), ModuleError>
Register global bare env var → top-level config key mappings.