Type Alias ResolveError

Source
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

§position: usize

Position (index) of the token which failed to parse as an Index

§offset: usize

Offset of the partial pointer starting with the invalid index.

§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

§position: usize

Position (index) of the token which failed to parse as an Index

§offset: usize

Offset of the partial pointer starting with the invalid index.

§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

§position: usize

Position (index) of the token which was not found.

§offset: usize

Offset of the pointer starting with the Token which was 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());

Fields

§position: usize

Position (index) of the token which was unreachable.

§offset: usize

Offset of the pointer which was unreachable.