pub enum Op {
Set {
path: Path,
value: Value,
},
Delete {
path: Path,
},
Append {
path: Path,
value: Value,
},
MergeObject {
path: Path,
value: Value,
},
Increment {
path: Path,
amount: Number,
},
Decrement {
path: Path,
amount: Number,
},
Insert {
path: Path,
index: usize,
value: Value,
},
Remove {
path: Path,
value: Value,
},
LatticeMerge {
path: Path,
value: Value,
},
}Expand description
A single patch operation.
Operations are the atomic units of change. Each operation targets a specific path in the document and performs a specific mutation.
Variants§
Set
Set a value at the path.
Creates intermediate objects if they don’t exist. Returns error if array index is out of bounds.
Delete
Delete the value at the path.
No-op if the path doesn’t exist.
Append
Append a value to an array at the path.
Creates the array if it doesn’t exist. Returns error if the target exists but is not an array.
MergeObject
Merge an object into the object at the path.
Creates the object if it doesn’t exist. Returns error if the target exists but is not an object.
Increment
Increment a numeric value at the path.
Returns error if the target is not a number.
Decrement
Decrement a numeric value at the path.
Returns error if the target is not a number.
Insert
Insert a value at a specific index in an array.
Shifts elements to the right. Returns error if index is out of bounds or target is not an array.
Fields
Remove
Remove the first occurrence of a value from an array.
No-op if the value is not found. Returns error if the target is not an array.
LatticeMerge
Merge a lattice delta into an existing value at path.
When applied via LatticeRegistry, performs a proper lattice merge.
Without a registry, falls back to Op::Set semantics (writes the delta directly).
Implementations§
Source§impl Op
impl Op
Sourcepub fn merge_object(path: Path, value: impl Into<Value>) -> Self
pub fn merge_object(path: Path, value: impl Into<Value>) -> Self
Create a MergeObject operation.
Sourcepub fn insert(path: Path, index: usize, value: impl Into<Value>) -> Self
pub fn insert(path: Path, index: usize, value: impl Into<Value>) -> Self
Create an Insert operation.
Sourcepub fn lattice_merge(path: Path, value: impl Into<Value>) -> Self
pub fn lattice_merge(path: Path, value: impl Into<Value>) -> Self
Create a LatticeMerge operation.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Op
impl<'de> Deserialize<'de> for Op
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Extend<Op> for Patch
impl Extend<Op> for Patch
Source§fn extend<I: IntoIterator<Item = Op>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = Op>>(&mut self, iter: I)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)