pub struct PatchOp(/* private fields */);
Expand description
A JSON Patch operation
From the official website:
JSON Patch is a format for describing changes to a JSON document. It can be used to avoid sending a whole document when only a part has changed.
Implementations§
Source§impl PatchOp
impl PatchOp
Sourcepub fn add<T>(path: &str, value: T) -> Selfwhere
T: Serialize,
pub fn add<T>(path: &str, value: T) -> Selfwhere
T: Serialize,
Adds a value to an object or inserts it into an array.
In the case of an array, the value is inserted before the given index.
The -
character can be used instead of an index to insert at the end of an array.
§Examples
PatchOp::add("/biscuits/1", json!({ "name": "Ginger Nut" }))
Sourcepub fn remove(path: &str) -> Self
pub fn remove(path: &str) -> Self
Removes a value from an object or array.
§Examples
PatchOp::remove("/biscuits")
Remove the first element of the array at biscuits
(or just removes the “0” key if biscuits
is an object)
PatchOp::remove("/biscuits/0")
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PatchOp
impl RefUnwindSafe for PatchOp
impl Send for PatchOp
impl Sync for PatchOp
impl Unpin for PatchOp
impl UnwindSafe for PatchOp
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more