pub type ResolveError = Error;
Expand description
Alias for Error
.
Aliased Type§
pub enum ResolveError {
FailedToParseIndex {
position: usize,
offset: usize,
source: ParseIndexError,
},
OutOfBounds {
position: usize,
offset: usize,
source: OutOfBoundsError,
},
NotFound {
position: usize,
offset: usize,
},
Unreachable {
position: usize,
offset: usize,
},
}
Variants§
FailedToParseIndex
Pointer
could not be resolved because a Token
for an array index is
not a valid integer or dash ("-"
).
§Example
let data = json!({ "foo": ["bar"] });
let ptr = Pointer::from_static("/foo/invalid");
assert!(ptr.resolve(&data).unwrap_err().is_failed_to_parse_index());
Fields
§
source: ParseIndexError
The source ParseIndexError
OutOfBounds
A Token
within the Pointer
contains an [Index
] which is out of
bounds.
§Example
let data = json!({ "foo": ["bar"] });
let ptr = Pointer::from_static("/foo/1");
assert!(ptr.resolve(&data).unwrap_err().is_out_of_bounds());
Fields
§
source: OutOfBoundsError
The source OutOfBoundsError
NotFound
Pointer
could not be resolved as a segment of the path was not found.
§Example
let mut data = json!({ "foo": "bar" });
let ptr = Pointer::from_static("/bar");
assert!(ptr.resolve(&data).unwrap_err().is_not_found());
Fields
Unreachable
Pointer
could not be resolved as the path contains a scalar value
before fully exhausting the path.
§Example
let mut data = json!({ "foo": "bar" });
let ptr = Pointer::from_static("/foo/unreachable");
let err = ptr.resolve(&data).unwrap_err();
assert!(err.is_unreachable());