Skip to main content

IncludeMerge

Struct IncludeMerge 

Source
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_identity are concatenated across documents and hard-error on duplicate identity;
  • map sections registered via IncludeMerge::with_unique_keys hard-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

Source

pub fn new() -> Self

Create an include-merge with no identity-keyed sections.

Source

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).

Source

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.

Source

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.

Trait Implementations§

Source§

impl Debug for IncludeMerge

Source§

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

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

impl Default for IncludeMerge

Source§

fn default() -> IncludeMerge

Returns the “default value” for a type. 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> 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, 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> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more