pub enum Operation {
Add {
path: Vec<Strand>,
value: Value,
},
Remove {
path: Vec<Strand>,
},
Replace {
path: Vec<Strand>,
value: Value,
},
Change {
path: Vec<Strand>,
value: Value,
},
Copy {
path: Vec<Strand>,
from: Vec<Strand>,
},
Move {
path: Vec<Strand>,
from: Vec<Strand>,
},
Test {
path: Vec<Strand>,
value: Value,
},
}Expand description
A type representing an delta change to a value.
Variants§
Implementations§
Source§impl Operation
impl Operation
Sourcepub fn walk_revisioned_variant_name(
wire_revision: u16,
discriminant: u32,
) -> Option<&'static str>
pub fn walk_revisioned_variant_name( wire_revision: u16, discriminant: u32, ) -> Option<&'static str>
Resolve a wire discriminant at wire_revision to the variant
identifier at that revision. Returns None if no such variant
exists at that revision.
Generated by the revisioned derive.
Sourcepub fn walk_revisioned_variant_table(
wire_revision: u16,
) -> &'static [(&'static str, u32)]
pub fn walk_revisioned_variant_table( wire_revision: u16, ) -> &'static [(&'static str, u32)]
Variant name + discriminant pairs at wire_revision. Returns
an empty slice if the revision is unknown. Generated by the
revisioned derive.
Source§impl Operation
impl Operation
Sourcepub fn array_index(token: &str) -> Option<usize>
pub fn array_index(token: &str) -> Option<usize>
The array index a JSON Pointer reference token names, if it names one.
RFC 6901 §4 spells an array index as 0 or [1-9][0-9]*. str::parse
is wider than that grammar — it also accepts a leading + and leading
zeroes — and those spellings name distinct object members, so the
parsed value is re-rendered and compared to reject them. The result is
bounded by usize on the target, which is the range an index part can
address.
Sourcepub fn path_to_parts(path: &[Strand]) -> Vec<Part>
pub fn path_to_parts(path: &[Strand]) -> Vec<Part>
Maps the reference tokens of a JSON Pointer to the parts that select the value it points at.
A token spelled as an array index becomes an index part, which selects
the element at that position in an array and the member of that name in
an object — the two readings RFC 6901 gives a token, and they agree
only because the spelling is canonical, so the member name an index
part derives is the token itself. Every other token becomes a field
part carrying it verbatim, which keeps members named 007, +3 or
-1 addressable.
Every pointer that Value::patch resolves is mapped here, so that a
caller deciding whether a pointer may be applied — see
Document::check_patch_read_pointers — judges the same location the
patch will reach.
Sourcepub fn into_object(self) -> Object
pub fn into_object(self) -> Object
Converts the operation to a JSON patch object.
Sourcepub fn operation_from_object(object: &Object) -> Result<Operation, PatchError>
pub fn operation_from_object(object: &Object) -> Result<Operation, PatchError>
Returns the operaton encoded in the object, or an error if the object does not contain a valid operation.
Sourcepub fn value_to_operations(value: Value) -> Result<Vec<Operation>, PatchError>
pub fn value_to_operations(value: Value) -> Result<Vec<Operation>, PatchError>
Turns a value into a list of operations if the value has the right structure.
pub fn operations_to_value(operations: Vec<Operation>) -> Value
Trait Implementations§
Source§impl DeserializeRevisioned for Operation
impl DeserializeRevisioned for Operation
impl Eq for Operation
Source§impl Revisioned for Operation
impl Revisioned for Operation
Source§impl SerializeRevisioned for Operation
impl SerializeRevisioned for Operation
Source§impl SkipCheckRevisioned for Operation
impl SkipCheckRevisioned for Operation
Source§impl SkipRevisioned for Operation
impl SkipRevisioned for Operation
fn skip_revisioned<R: Read>(reader: &mut R) -> Result<(), Error>
Source§fn skip_revisioned_slice(reader: &mut SliceReader<'_>) -> Result<(), Error>
fn skip_revisioned_slice(reader: &mut SliceReader<'_>) -> Result<(), Error>
SliceReader without allocating a buffer for bulk segments. Read moreimpl StructuralPartialEq for Operation
Source§impl WalkRevisioned for Operation
impl WalkRevisioned for Operation
Source§type Walker<'r, R: BorrowedReader + 'r> = OperationWalker<'r, R>
type Walker<'r, R: BorrowedReader + 'r> = OperationWalker<'r, R>
walk_revisioned. Read moreSource§fn walk_revisioned<'r, R: BorrowedReader>(
reader: &'r mut R,
) -> Result<Self::Walker<'r, R>, Error>
fn walk_revisioned<'r, R: BorrowedReader>( reader: &'r mut R, ) -> Result<Self::Walker<'r, R>, Error>
Auto Trait Implementations§
impl !Freeze for Operation
impl !RefUnwindSafe for Operation
impl !UnwindSafe for Operation
impl Send for Operation
impl Sync for Operation
impl Unpin for Operation
impl UnsafeUnpin for Operation
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.