[−][src]Struct crdt_tree::opmove::OpMove
From the paper:
We allow the tree to be updated in three ways: by creating a new child of any parent node, by deleting a node, or by moving a node to be a child of a new parent. However all three types of update can be represented by a move operation. To create a node, we generate a fresh ID for that node, and issue an operation to move this new ID to be created. We also designate as "trash" some node ID that does not exist in the tree; then we can delete a node by moving it to be a child of the trash.
Thus, we define one kind of operation: Move t p m c. A move operation is a 4-tuple consisting of a timestamp t of type 't, a parent node ID p of type 'n, a metadata field m of type 'm, and a child node ID c of type 'n. Here, 't, 'n, and 'm are type variables that can be replaced with arbitrary types; we only require that node identifiers 'n are globally unique (eg UUIDs); timestamps 't need to be globally unique and totally ordered (eg Lamport timestamps [11]).
The meaning of an operation Move t p m c is that at time t, the node with ID c is moved to be a child of the parent node with ID p. The operation does not specify the old location of c; the algorithm simply removes c from wherever it is currently located in the tree, and moves it to p. If c does not currently exist in the tree, it is created as a child of p.
The metadata field m in a move operation allows additional information to be associated with the parent-child relationship of p and c. For example, in a filesystem, the parent and child are the inodes of a directory and a file within it respectively, and the metadata contains the filename of the child. Thus, a file with inode c can be renamed by performing a Move t p m c, where the new parent directory p is the inode of the existing parent (unchanged), but the metadata m contains the new filename.
When users want to make changes to the tree on their local replica they generate new Move t p m c operations for these changes, and apply these operations using the algorithm described...
Implementations
impl<ID: TreeId, TM: TreeMeta, A: Actor> OpMove<ID, TM, A>
[src]
pub fn new(
timestamp: Clock<A>,
parent_id: ID,
metadata: TM,
child_id: ID
) -> Self
[src]
timestamp: Clock<A>,
parent_id: ID,
metadata: TM,
child_id: ID
) -> Self
create a new OpMove instance
pub fn timestamp(&self) -> &Clock<A>
[src]
returns timestamp reference
pub fn parent_id(&self) -> &ID
[src]
returns parent_id reference
pub fn metadata(&self) -> &TM
[src]
returns metadata reference
pub fn child_id(&self) -> &ID
[src]
returns child_id reference
Trait Implementations
impl<ID: TreeId + Arbitrary, A: Actor + Arbitrary, TM: TreeMeta + Arbitrary> Arbitrary for OpMove<ID, TM, A>
[src]
fn arbitrary<G: Gen>(g: &mut G) -> Self
[src]
generates an arbitrary (random) OpMove
fn shrink(&self) -> Box<dyn Iterator<Item = Self> + 'static>
[src]
impl<ID: Clone + TreeId, TM: Clone + TreeMeta, A: Clone + Actor> Clone for OpMove<ID, TM, A>
[src]
impl<ID: Debug + TreeId, TM: Debug + TreeMeta, A: Debug + Actor> Debug for OpMove<ID, TM, A>
[src]
impl<'de, ID: TreeId, TM: TreeMeta, A: Actor> Deserialize<'de> for OpMove<ID, TM, A> where
ID: Deserialize<'de>,
TM: Deserialize<'de>,
A: Deserialize<'de>,
[src]
ID: Deserialize<'de>,
TM: Deserialize<'de>,
A: Deserialize<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl<ID: Eq + TreeId, TM: Eq + TreeMeta, A: Eq + Actor> Eq for OpMove<ID, TM, A>
[src]
impl<ID: TreeId, A: Actor, TM: TreeMeta> From<LogOpMove<ID, TM, A>> for OpMove<ID, TM, A>
[src]
impl<ID: PartialEq + TreeId, TM: PartialEq + TreeMeta, A: PartialEq + Actor> PartialEq<OpMove<ID, TM, A>> for OpMove<ID, TM, A>
[src]
fn eq(&self, other: &OpMove<ID, TM, A>) -> bool
[src]
fn ne(&self, other: &OpMove<ID, TM, A>) -> bool
[src]
impl<ID: TreeId, TM: TreeMeta, A: Actor> Serialize for OpMove<ID, TM, A> where
ID: Serialize,
TM: Serialize,
A: Serialize,
[src]
ID: Serialize,
TM: Serialize,
A: Serialize,
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl<ID: TreeId, TM: TreeMeta, A: Actor> StructuralEq for OpMove<ID, TM, A>
[src]
impl<ID: TreeId, TM: TreeMeta, A: Actor> StructuralPartialEq for OpMove<ID, TM, A>
[src]
Auto Trait Implementations
impl<ID, TM, A> RefUnwindSafe for OpMove<ID, TM, A> where
A: RefUnwindSafe,
ID: RefUnwindSafe,
TM: RefUnwindSafe,
A: RefUnwindSafe,
ID: RefUnwindSafe,
TM: RefUnwindSafe,
impl<ID, TM, A> Send for OpMove<ID, TM, A> where
A: Send,
ID: Send,
TM: Send,
A: Send,
ID: Send,
TM: Send,
impl<ID, TM, A> Sync for OpMove<ID, TM, A> where
A: Sync,
ID: Sync,
TM: Sync,
A: Sync,
ID: Sync,
TM: Sync,
impl<ID, TM, A> Unpin for OpMove<ID, TM, A> where
A: Unpin,
ID: Unpin,
TM: Unpin,
A: Unpin,
ID: Unpin,
TM: Unpin,
impl<ID, TM, A> UnwindSafe for OpMove<ID, TM, A> where
A: UnwindSafe,
ID: UnwindSafe,
TM: UnwindSafe,
A: UnwindSafe,
ID: UnwindSafe,
TM: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<TM> TreeMeta for TM where
TM: Clone,
[src]
TM: Clone,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,