pub enum PathError {
Parse(PathParseError),
EmptyPath,
NoRoot,
TypeMismatch {
at: String,
},
NotFound {
at: String,
},
AliasRefused {
at: String,
alias: String,
},
IndexTooFar {
at: String,
len: usize,
index: usize,
},
UndefinedAlias {
at: String,
alias: String,
},
InvalidMergeOperand {
at: String,
operand: String,
},
}Expand description
Error returned by try_get_path /
try_set_path /
try_remove_path.
Distinguishes the several ways a path operation can fail so callers
can react appropriately, instead of getting the previous silent
no-op or ambiguous None.
Variants§
Parse(PathParseError)
The path string is malformed; see PathParseError.
EmptyPath
The path is the empty string. Stray dots are a
PathParseError::EmptySegment instead.
NoRoot
The receiver has no root value to descend into: Document was
empty, or the requested operation needed a root mapping and the
document’s root is a scalar / sequence.
TypeMismatch
A segment tried to descend into a value of the wrong container
type – e.g. treating a scalar as a mapping in foo.bar when
foo is a scalar. at is the segment index ("foo" in the
example above) that led to the type mismatch.
NotFound
The target segment does not exist. Applies to
try_get_path and
try_remove_path; try_set_path
creates missing intermediates and never reports this. at is
the missing segment.
AliasRefused
A segment landed on an alias (*name) and the active
AliasPolicy refused to go through it. at is the segment,
alias the anchor name it referenced.
Fields
IndexTooFar
Setting the requested index would have grown a sequence by more
than MAX_INDEX_GROWTH null placeholders.
try_set_path("s[900000]", v) on a short sequence would otherwise
pad it with that many entries, so a path from untrusted input could
spend unbounded time and memory.
Fields
UndefinedAlias
A segment landed on an alias whose anchor is not defined anywhere
in the document, so it could not be resolved. Also reported when a
<< merge operand consulted for the segment is such an alias.
Fields
InvalidMergeOperand
Looking up a segment needed the mapping’s merge keys, and a <<
operand was neither a mapping nor an alias to one.
Trait Implementations§
impl Eq for PathError
Source§impl Error for PathError
impl Error for PathError
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()