pub enum PatchOperationRef<'a> {
Add {
path: Cow<'a, str>,
value: Cow<'a, Value>,
},
Remove {
path: Cow<'a, str>,
},
Replace {
path: Cow<'a, str>,
value: Cow<'a, Value>,
},
Move {
from: Cow<'a, str>,
path: Cow<'a, str>,
},
Copy {
from: Cow<'a, str>,
path: Cow<'a, str>,
},
Test {
path: Cow<'a, str>,
value: Cow<'a, Value>,
},
}Expand description
A single patch operation with zero-copy paths where possible.
Variants§
Add
Add a value at the specified path.
Remove
Remove the value at the specified path.
Replace
Replace the value at the specified path.
Move
Move a value from one path to another.
Copy
Copy a value from one path to another.
Test
Test that a value equals the expected value.
Implementations§
Source§impl<'a> PatchOperationRef<'a>
impl<'a> PatchOperationRef<'a>
Sourcepub const fn add(path: String, value: &'a Value) -> Self
pub const fn add(path: String, value: &'a Value) -> Self
Create an Add operation with owned path and borrowed value.
Sourcepub const fn replace(path: String, value: &'a Value) -> Self
pub const fn replace(path: String, value: &'a Value) -> Self
Create a Replace operation with owned path and borrowed value.
Sourcepub const fn move_op(from: String, path: String) -> Self
pub const fn move_op(from: String, path: String) -> Self
Create a Move operation with owned paths.
Sourcepub const fn copy(from: String, path: String) -> Self
pub const fn copy(from: String, path: String) -> Self
Create a Copy operation with owned paths.
Sourcepub const fn test(path: String, value: &'a Value) -> Self
pub const fn test(path: String, value: &'a Value) -> Self
Create a Test operation with owned path and borrowed value.
Sourcepub fn into_owned(self) -> PatchOperationRef<'static>
pub fn into_owned(self) -> PatchOperationRef<'static>
Convert to owned version (for storing beyond borrow lifetime).
Trait Implementations§
Source§impl<'a> Clone for PatchOperationRef<'a>
impl<'a> Clone for PatchOperationRef<'a>
Source§fn clone(&self) -> PatchOperationRef<'a>
fn clone(&self) -> PatchOperationRef<'a>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl<'a> Freeze for PatchOperationRef<'a>
impl<'a> RefUnwindSafe for PatchOperationRef<'a>
impl<'a> Send for PatchOperationRef<'a>
impl<'a> Sync for PatchOperationRef<'a>
impl<'a> Unpin for PatchOperationRef<'a>
impl<'a> UnwindSafe for PatchOperationRef<'a>
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
Mutably borrows from an owned value. Read more