pub struct Config {
pub scope: ScopeConfig,
pub kinds: KindsConfig,
pub statuses: StatusesConfig,
pub identity: IdentityConfig,
pub schema: SchemaConfig,
pub rules: RulesConfig,
pub parser: ParserConfig,
pub detection: DetectionConfig,
pub output: OutputConfig,
pub report: ReportConfig,
}Expand description
Root configuration deserialized from nodex.toml.
Fields§
§scope: ScopeConfig§kinds: KindsConfig§statuses: StatusesConfig§identity: IdentityConfig§schema: SchemaConfig§rules: RulesConfig§parser: ParserConfig§detection: DetectionConfig§output: OutputConfig§report: ReportConfigImplementations§
Source§impl Config
impl Config
Sourcepub fn load(root: &Path) -> Result<Self>
pub fn load(root: &Path) -> Result<Self>
Load config from a nodex.toml file. Returns default config if not found.
Config is validated for internal consistency before it is returned,
so downstream code can assume that enums / cross_field references
are well-formed.
Sourcepub fn validate(&self) -> Result<()>
pub fn validate(&self) -> Result<()>
Validate internal consistency. Called automatically by load().
Rejects definitions that would otherwise only surface as confusing runtime behaviour:
enumson collection-valued built-in fields (tags,supersedes,implements,related) — these cannot be validated against a scalar set, so silent ignore would trap users who typed the obvious syntax and saw no effect.enums.status/enums.kindvalues that are not in the corresponding globalallowedlist.cross_field.whenexpressions that don’t parse.cross_field.when’s LHS andcross_field.requirereferring to a field name that is not a built-in scalar and is not declared in the override’stypes/enums/required.
Sourcepub fn types_for(&self, kind: &str) -> BTreeMap<String, FieldType>
pub fn types_for(&self, kind: &str) -> BTreeMap<String, FieldType>
Merged view: return every field-type constraint that applies to a given kind (global + first matching override). Scaffold and rules use this so every declared constraint is honoured once.
Sourcepub fn enums_for(&self, kind: &str) -> BTreeMap<String, Vec<String>>
pub fn enums_for(&self, kind: &str) -> BTreeMap<String, Vec<String>>
Merged view: every enum constraint that applies to a given kind.
Sourcepub fn cross_field_for(&self, kind: &str) -> Vec<CrossFieldSpec>
pub fn cross_field_for(&self, kind: &str) -> Vec<CrossFieldSpec>
Merged view: every cross-field constraint that applies to a given kind. Global and override entries accumulate; an override never silently drops a global rule.
Sourcepub fn is_terminal(&self, status: &str) -> bool
pub fn is_terminal(&self, status: &str) -> bool
Check whether a status string is terminal.
Sourcepub fn is_orphan_ok_kind(&self, kind: &str) -> bool
pub fn is_orphan_ok_kind(&self, kind: &str) -> bool
Whether nodes of the given kind are exempt from orphan detection.
Driven by detection.orphan_ok_kinds. Pairs with the per-instance
node.orphan_ok opt-out so callers can express both “this entire
kind is leaf-by-design” and “this specific document is exceptional”.
Named to mirror the field and the per-node flag, paralleling
is_terminal ↔ statuses.terminal.
Sourcepub fn required_for(&self, kind: &str) -> &[String]
pub fn required_for(&self, kind: &str) -> &[String]
Get required fields for a given kind. Falls back to the global
schema.required list when no override matches.
Sourcepub fn schema_override_for(&self, kind: &str) -> Option<&SchemaOverride>
pub fn schema_override_for(&self, kind: &str) -> Option<&SchemaOverride>
Find the schema override that applies to a given kind, if any.
Sourcepub fn initial_status_for(&self, kind: &str) -> &str
pub fn initial_status_for(&self, kind: &str) -> &str
The status value that tool-level actions (scaffold, migrate)
should write when they create a new document of a given kind.
Walks from the narrowest declaration to the broadest: per-kind
override’s enums.status, then the global schema.enums.status,
then statuses.allowed. The first hit’s first() wins.
Config::validate guarantees each of these is either absent or
non-empty, and that any enums.status covers the four lifecycle
targets — so the result is always in-vocabulary and the invariant
holding migrate / scaffold together with check never breaks.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Config
impl<'de> Deserialize<'de> for Config
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnsafeUnpin for Config
impl UnwindSafe for Config
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more