Enum jsonptr::resolve::ResolveError
source · pub enum ResolveError {
FailedToParseIndex {
offset: usize,
source: ParseIndexError,
},
OutOfBounds {
offset: usize,
source: OutOfBoundsError,
},
NotFound {
offset: usize,
},
Unreachable {
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
Pointer could not be resolved due to an index being out of bounds
within an array.
§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());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 ResolveError
impl ResolveError
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 Debug for ResolveError
impl Debug for ResolveError
source§impl Display for ResolveError
impl Display for ResolveError
source§impl Error for ResolveError
impl Error for ResolveError
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
source§impl PartialEq for ResolveError
impl PartialEq for ResolveError
source§fn eq(&self, other: &ResolveError) -> bool
fn eq(&self, other: &ResolveError) -> bool
self and other values to be equal, and is used
by ==.