pub enum Error {
FailedToParseIndex {
position: usize,
offset: usize,
source: ParseIndexError,
},
OutOfBounds {
position: usize,
offset: usize,
source: OutOfBoundsError,
},
NotFound {
position: usize,
offset: usize,
},
Unreachable {
position: usize,
offset: usize,
},
}Expand description
Indicates that the Pointer could not be resolved.
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: ParseIndexErrorThe 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: OutOfBoundsErrorThe 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());Implementations§
Source§impl Error
impl Error
Sourcepub fn offset(&self) -> usize
pub fn offset(&self) -> usize
Offset of the partial pointer starting with the token which caused the error.
Sourcepub fn is_unreachable(&self) -> bool
pub fn is_unreachable(&self) -> bool
Returns true if this error is FailedToParseIndex; otherwise returns
false.
Sourcepub fn is_not_found(&self) -> bool
pub fn is_not_found(&self) -> bool
Returns true if this error is FailedToParseIndex; otherwise returns
false.
Sourcepub fn is_out_of_bounds(&self) -> bool
pub fn is_out_of_bounds(&self) -> bool
Returns true if this error is FailedToParseIndex; otherwise returns
false.
Sourcepub fn is_failed_to_parse_index(&self) -> bool
pub fn is_failed_to_parse_index(&self) -> bool
Returns true if this error is FailedToParseIndex; otherwise returns
false.