Applies a LeafOp to the pristine database. This is the main entry point for applying token-level operations. # Arguments `txn` - The transaction to apply the operation in `context` - The apply context for tracking state and conflicts `branch_id` - The parent branch (line) this leaf belongs to `leaf_id` - The ID for the leaf (for Insert ops, this is the new ID) `op` - The operation to apply `con
(
txn: &mut T,
context: &mut ApplyContext,
branch_id: BranchId,
leaf_id: LeafId,
op: &LeafOp,
content: &[u8],
)
| 99 | /// apply_leaf_op(&mut txn, &mut context, branch_id, leaf_id, &op, content)?; |
| 100 | /// ``` |
| 101 | pub fn apply_leaf_op<T: MutCrdtTxnT>( |
| 102 | txn: &mut T, |
| 103 | context: &mut ApplyContext, |
| 104 | branch_id: BranchId, |
| 105 | leaf_id: LeafId, |
| 106 | op: &LeafOp, |
| 107 | content: &[u8], |
| 108 | ) -> ApplyResult<()> { |
| 109 | match op { |
| 110 | LeafOp::Insert { |
| 111 | after, |
| 112 | kind, |
| 113 | content: leaf_content, |
| 114 | } => apply_insert( |
| 115 | txn, |
| 116 | context, |
| 117 | branch_id, |
| 118 | leaf_id, |
| 119 | *after, |
| 120 | *kind, |
| 121 | leaf_content, |
| 122 | content, |
| 123 | ), |
| 124 | LeafOp::Delete { leaf } => apply_delete(txn, context, *leaf), |
| 125 | LeafOp::Replace { leaf, new_content } => { |
| 126 | apply_replace(txn, context, *leaf, new_content, content) |
| 127 | } |
| 128 | LeafOp::Restore { leaf } => apply_restore(txn, context, *leaf), |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | // Insert Operation |
| 133 |