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,
},
}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 (unclosed [, non-usize index).
EmptyPath
The path parsed to zero segments (typically the empty string or a run of stray dots).
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.
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()