pub struct MergePolicyRegistry { /* private fields */ }Expand description
Domain-level conflict resolver selected by key.
Implementations§
Source§impl MergePolicyRegistry
impl MergePolicyRegistry
Sourcepub fn with_default<F>(policy: F) -> Self
pub fn with_default<F>(policy: F) -> Self
Create a registry with a default policy for unmatched keys.
Sourcepub fn set_default<F>(&mut self, policy: F) -> &mut Self
pub fn set_default<F>(&mut self, policy: F) -> &mut Self
Set the default policy for unmatched keys.
Sourcepub fn default_policy<F>(self, policy: F) -> Self
pub fn default_policy<F>(self, policy: F) -> Self
Builder-style default policy registration.
Sourcepub fn push_prefix<F>(
&mut self,
prefix: impl Into<Vec<u8>>,
policy: F,
) -> &mut Self
pub fn push_prefix<F>( &mut self, prefix: impl Into<Vec<u8>>, policy: F, ) -> &mut Self
Add a policy for keys starting with prefix.
Rules are evaluated from newest to oldest, so later rules override earlier broader rules.
Sourcepub fn add_prefix<F>(self, prefix: impl Into<Vec<u8>>, policy: F) -> Self
pub fn add_prefix<F>(self, prefix: impl Into<Vec<u8>>, policy: F) -> Self
Builder-style prefix policy registration.
Sourcepub fn push_exact<F>(&mut self, key: impl Into<Vec<u8>>, policy: F) -> &mut Self
pub fn push_exact<F>(&mut self, key: impl Into<Vec<u8>>, policy: F) -> &mut Self
Add a policy for one exact key.
Rules are evaluated from newest to oldest, so later rules override earlier broader rules.
Sourcepub fn add_exact<F>(self, key: impl Into<Vec<u8>>, policy: F) -> Self
pub fn add_exact<F>(self, key: impl Into<Vec<u8>>, policy: F) -> Self
Builder-style exact-key policy registration.
Sourcepub fn push_pattern<M, F>(
&mut self,
name: impl Into<String>,
matcher: M,
policy: F,
) -> &mut Self
pub fn push_pattern<M, F>( &mut self, name: impl Into<String>, matcher: M, policy: F, ) -> &mut Self
Add a policy selected by a custom key matcher.
name is used only for diagnostics and debugging.
Sourcepub fn add_pattern<M, F>(
self,
name: impl Into<String>,
matcher: M,
policy: F,
) -> Self
pub fn add_pattern<M, F>( self, name: impl Into<String>, matcher: M, policy: F, ) -> Self
Builder-style custom key matcher policy registration.
Sourcepub fn has_default(&self) -> bool
pub fn has_default(&self) -> bool
Whether a default policy is configured for unmatched keys.
Sourcepub fn rules(&self) -> &[MergePolicyRule]
pub fn rules(&self) -> &[MergePolicyRule]
Borrow registered rules in insertion order.
Sourcepub fn matching_rule(&self, key: &[u8]) -> Option<&MergePolicyRule>
pub fn matching_rule(&self, key: &[u8]) -> Option<&MergePolicyRule>
Return the newest matching key-specific rule, if any.
Sourcepub fn resolve(&self, conflict: &Conflict) -> Resolution
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.
Sourcepub fn into_resolver(self) -> Resolver
pub fn into_resolver(self) -> Resolver
Convert this registry into a standard merge resolver.
Sourcepub fn as_resolver(&self) -> Resolver
pub fn as_resolver(&self) -> Resolver
Clone this registry into a standard merge resolver.
Trait Implementations§
Source§impl Clone for MergePolicyRegistry
impl Clone for MergePolicyRegistry
Source§fn clone(&self) -> MergePolicyRegistry
fn clone(&self) -> MergePolicyRegistry
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MergePolicyRegistry
impl Debug for MergePolicyRegistry
Auto Trait Implementations§
impl !RefUnwindSafe for MergePolicyRegistry
impl !UnwindSafe for MergePolicyRegistry
impl Freeze for MergePolicyRegistry
impl Send for MergePolicyRegistry
impl Sync for MergePolicyRegistry
impl Unpin for MergePolicyRegistry
impl UnsafeUnpin for MergePolicyRegistry
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