#[non_exhaustive]pub enum MergePatchError {
DepthExceeded,
}Expand description
Error returned by json_merge_patch when a patch cannot be applied.
Marked #[non_exhaustive] so future RFC 7396 failure modes (e.g. a
size cap in addition to the depth cap) can be added without an API
break.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
DepthExceeded
The patch nests deeper than the crate’s MAX_MERGE_PATCH_DEPTH
DoS-guard cap.
Callers SHOULD map this to
SetError with
SetErrorType::InvalidPatch
and MUST discard any partially-mutated target rather than
persisting it — see the contract on json_merge_patch.
§Why no reached / max payload (bd:JMAP-jfia.39)
The variant is intentionally unit-shaped. The cap value is
available in the Display impl (which interpolates
MAX_MERGE_PATCH_DEPTH) for log-line and user-message use.
A typed payload { reached: usize, max: usize } was
considered and rejected for now because (a) no current
consumer in the workspace destructures the reached depth or
the cap programmatically — all 6 call sites map to
SetErrorType::InvalidPatch with a generic description; and
(b) changing a unit variant to a struct variant is a breaking
pattern-match change even on a #[non_exhaustive] enum (the
existing if let Err(MergePatchError::DepthExceeded) pattern
would stop compiling). If a future consumer needs
programmatic access to the depth, the additive evolution is
to add a new variant alongside (e.g.
DepthExceededDetail { reached: usize, max: usize }) and
emit the new variant from json_merge_patch. The unit
variant would then become unreachable but remain valid
pattern syntax for any pinned-version consumer.
Trait Implementations§
Source§impl Clone for MergePatchError
impl Clone for MergePatchError
Source§fn clone(&self) -> MergePatchError
fn clone(&self) -> MergePatchError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MergePatchError
impl Debug for MergePatchError
Source§impl Display for MergePatchError
impl Display for MergePatchError
impl Eq for MergePatchError
Source§impl Error for MergePatchError
impl Error for MergePatchError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl PartialEq for MergePatchError
impl PartialEq for MergePatchError
Source§fn eq(&self, other: &MergePatchError) -> bool
fn eq(&self, other: &MergePatchError) -> bool
self and other values to be equal, and is used by ==.