pub struct IncludeMerge { /* private fields */ }Expand description
Identity-aware include-merge configuration.
Merges config documents with deterministic, schema-aware rules:
- tables merge recursively; on a scalar key collision the overlay value wins (last-wins scalars);
- array-of-tables sections registered via
IncludeMerge::with_identityare concatenated across documents and hard-error on duplicate identity; - map sections registered via
IncludeMerge::with_unique_keyshard-error when the same map key is contributed by more than one document (a duplicate identity for sections keyed by name rather than by an array element); - any other array is replaced wholesale by the overlay.
Implementations§
Source§impl IncludeMerge
impl IncludeMerge
Sourcepub fn with_identity(
self,
section: impl Into<String>,
identity: impl MergeIdentity + 'static,
) -> Self
pub fn with_identity( self, section: impl Into<String>, identity: impl MergeIdentity + 'static, ) -> Self
Register section as an identity-keyed array-of-tables.
Such sections are concatenated across documents
and hard-error on a duplicate identity (see IdentityKey / CompositeKey).
Sourcepub fn with_unique_keys(self, section: impl Into<String>) -> Self
pub fn with_unique_keys(self, section: impl Into<String>) -> Self
Register section as a map whose keys must be unique across documents.
Use this for sections modelled as a table-of-tables keyed by name (for example [groups.<name>]):
a key contributed by two documents is a duplicate identity and a hard error,
rather than a silent recursive merge.
Sourcepub fn merge(&self, base: Value, overlay: Value) -> AppResult<Value>
pub fn merge(&self, base: Value, overlay: Value) -> AppResult<Value>
Merge overlay onto base, returning the combined document.
Delegates the value-tree mechanics to rskit_codec::value::merge_with: objects merge recursively,
scalars are last-wins,
and arrays under a registered identity section are concatenated (all others replaced).
Before merging,
any with_unique_keys section is checked for keys present in both documents,
since the recursive merge would otherwise silently collapse the collision.
§Errors
Returns AppError when a unique-key section receives the same key from both documents.