Skip to main content

SetBias

Trait SetBias 

Source
pub trait SetBias:
    Default
    + Clone
    + Send
    + 'static {
    // Required method
    fn resolve(
        local_has_dots: bool,
        remote_has_dots: bool,
        local_removed: bool,
        remote_removed: bool,
    ) -> bool;
}
Expand description

Resolution strategy for concurrent add/remove conflicts.

When a replica adds an element while another concurrently removes it, the bias determines which operation wins. This trait defines the conflict resolution policy.

§Built-in Strategies

  • AddWins: Concurrent add survives concurrent remove (optimistic)
  • RemoveWins: Concurrent remove beats concurrent add (conservative)

§Implementation

Implement this trait to create custom conflict resolution strategies. The resolve method receives information about the local and remote states and returns true if the element should be kept.

Required Methods§

Source

fn resolve( local_has_dots: bool, remote_has_dots: bool, local_removed: bool, remote_removed: bool, ) -> bool

Resolve whether to keep an element based on concurrent operations.

§Parameters
  • local_has_dots: This replica has active dots for the element
  • remote_has_dots: Other replica has active dots for the element
  • local_removed: This replica saw and removed the element
  • remote_removed: Other replica saw and removed the element
§Returns

true if the element should be kept, false if it should be removed.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§