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: 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());
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
.
Trait Implementations§
Source§impl Diagnostic for Error
impl Diagnostic for Error
Source§impl Error for Error
impl Error for Error
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
impl Eq for Error
impl StructuralPartialEq for Error
Auto Trait Implementations§
impl Freeze for Error
impl RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnwindSafe for Error
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.