Skip to main content

Config

Struct Config 

Source
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: ReportConfig

Implementations§

Source§

impl Config

Source

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.

Source

pub fn validate(&self) -> Result<()>

Validate internal consistency. Called automatically by load().

Rejects definitions that would otherwise only surface as confusing runtime behaviour:

  • enums on 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.kind values that are not in the corresponding global allowed list.
  • cross_field.when expressions that don’t parse.
  • cross_field.when’s LHS and cross_field.require referring to a field name that is not a built-in scalar and is not declared in the override’s types / enums / required.
Source

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.

Source

pub fn enums_for(&self, kind: &str) -> BTreeMap<String, Vec<String>>

Merged view: every enum constraint that applies to a given kind.

Source

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.

Source

pub fn is_terminal(&self, status: &str) -> bool

Check whether a status string is terminal.

Source

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_terminalstatuses.terminal.

Source

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.

Source

pub fn schema_override_for(&self, kind: &str) -> Option<&SchemaOverride>

Find the schema override that applies to a given kind, if any.

Source

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 Clone for Config

Source§

fn clone(&self) -> Config

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Config

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Config

Source§

fn default() -> Config

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Config

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Config

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,