Skip to main content

MergePolicyRegistry

Struct MergePolicyRegistry 

Source
pub struct MergePolicyRegistry { /* private fields */ }
Expand description

Domain-level conflict resolver selected by key.

Implementations§

Source§

impl MergePolicyRegistry

Source

pub fn new() -> Self

Create an empty registry.

Source

pub fn with_default<F>(policy: F) -> Self
where F: Fn(&Conflict) -> Resolution + Send + Sync + 'static,

Create a registry with a default policy for unmatched keys.

Source

pub fn set_default<F>(&mut self, policy: F) -> &mut Self
where F: Fn(&Conflict) -> Resolution + Send + Sync + 'static,

Set the default policy for unmatched keys.

Source

pub fn default_policy<F>(self, policy: F) -> Self
where F: Fn(&Conflict) -> Resolution + Send + Sync + 'static,

Builder-style default policy registration.

Source

pub fn push_prefix<F>( &mut self, prefix: impl Into<Vec<u8>>, policy: F, ) -> &mut Self
where F: Fn(&Conflict) -> Resolution + Send + Sync + 'static,

Add a policy for keys starting with prefix.

Rules are evaluated from newest to oldest, so later rules override earlier broader rules.

Source

pub fn add_prefix<F>(self, prefix: impl Into<Vec<u8>>, policy: F) -> Self
where F: Fn(&Conflict) -> Resolution + Send + Sync + 'static,

Builder-style prefix policy registration.

Source

pub fn push_exact<F>(&mut self, key: impl Into<Vec<u8>>, policy: F) -> &mut Self
where F: Fn(&Conflict) -> Resolution + Send + Sync + 'static,

Add a policy for one exact key.

Rules are evaluated from newest to oldest, so later rules override earlier broader rules.

Source

pub fn add_exact<F>(self, key: impl Into<Vec<u8>>, policy: F) -> Self
where F: Fn(&Conflict) -> Resolution + Send + Sync + 'static,

Builder-style exact-key policy registration.

Source

pub fn push_pattern<M, F>( &mut self, name: impl Into<String>, matcher: M, policy: F, ) -> &mut Self
where M: Fn(&[u8]) -> bool + Send + Sync + 'static, F: Fn(&Conflict) -> Resolution + Send + Sync + 'static,

Add a policy selected by a custom key matcher.

name is used only for diagnostics and debugging.

Source

pub fn add_pattern<M, F>( self, name: impl Into<String>, matcher: M, policy: F, ) -> Self
where M: Fn(&[u8]) -> bool + Send + Sync + 'static, F: Fn(&Conflict) -> Resolution + Send + Sync + 'static,

Builder-style custom key matcher policy registration.

Source

pub fn len(&self) -> usize

Number of registered key-specific rules.

Source

pub fn is_empty(&self) -> bool

Whether no key-specific rules are registered.

Source

pub fn has_default(&self) -> bool

Whether a default policy is configured for unmatched keys.

Source

pub fn rules(&self) -> &[MergePolicyRule]

Borrow registered rules in insertion order.

Source

pub fn matching_rule(&self, key: &[u8]) -> Option<&MergePolicyRule>

Return the newest matching key-specific rule, if any.

Source

pub fn resolve(&self, conflict: &Conflict) -> Resolution

Resolve one conflict using the newest matching rule or the default.

If no rule matches and no default policy exists, the conflict is left unresolved.

Source

pub fn into_resolver(self) -> Resolver

Convert this registry into a standard merge resolver.

Source

pub fn as_resolver(&self) -> Resolver

Clone this registry into a standard merge resolver.

Trait Implementations§

Source§

impl Clone for MergePolicyRegistry

Source§

fn clone(&self) -> MergePolicyRegistry

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for MergePolicyRegistry

Source§

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

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

impl Default for MergePolicyRegistry

Source§

fn default() -> Self

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