pub fn json_merge_patch(
target: &mut Value,
patch: Value,
) -> Result<(), MergePatchError>Expand description
Apply a JSON Merge Patch (RFC 7396) to target in-place.
Used by every *-server backend’s update_object implementation
to merge a sparse /set update patch into the stored serialized
object. Extracted from per-crate copies in bd:JMAP-sc1b.103 — keep
edits here so all five reference backends stay byte-identical.
§Errors
Returns MergePatchError::DepthExceeded when the patch nests
deeper than the crate’s internal MAX_MERGE_PATCH_DEPTH DoS-guard
cap (added in bd:JMAP-sc1b.97, made non-silent in bd:JMAP-wlip.1).
The exact value is intentionally not exposed; consumers see the
behaviour via the typed error rather than reading the constant.
Below the cap the behaviour is exactly RFC 7396 and the call always
returns Ok(()).
§Partial-mutation contract
On Err(DepthExceeded), target may have been mutated up to the
level where the cap fired — RFC 7396 merging is applied recursively
in place and the function does not roll back on error. Callers MUST
discard target rather than persist it. The standard pattern in
every *-server update_object impl is to operate on a .clone()
of the stored value and only insert(...) it back on Ok(()); that
pattern is naturally safe because the stored value is left untouched
on error.