Enum ParseError

Source
pub enum ParseError {
    NoLeadingSlash,
    InvalidEncoding {
        offset: usize,
        source: EncodingError,
    },
}
Expand description

Indicates that a Pointer was malformed and unable to be parsed.

Variants§

§

NoLeadingSlash

Pointer did not start with a slash ('/').

§

InvalidEncoding

Pointer contained invalid encoding (e.g. ~ not followed by 0 or 1).

Fields

§offset: usize

Offset of the partial pointer starting with the token that contained the invalid encoding

§source: EncodingError

The source InvalidEncodingError

Implementations§

Source§

impl ParseError

Source

pub fn offset(&self) -> usize

Offset of the partial pointer starting with the token that contained the invalid encoding

Source

pub fn invalid_encoding_len(&self, subject: &str) -> usize

Length of the invalid encoding

Source§

impl ParseError

Source

pub fn is_no_leading_backslash(&self) -> bool

👎Deprecated since 0.7.0: renamed to is_no_leading_slash

Returns true if this error is NoLeadingSlash

Source

pub fn is_no_leading_slash(&self) -> bool

Returns true if this error is NoLeadingSlash

Source

pub fn is_invalid_encoding(&self) -> bool

Returns true if this error is InvalidEncoding

Source

pub fn pointer_offset(&self) -> usize

Offset of the partial pointer starting with the token which caused the error.

"/foo/invalid~tilde/invalid"
     ↑
let err = PointerBuf::parse("/foo/invalid~tilde/invalid").unwrap_err();
assert_eq!(err.pointer_offset(), 4)
Source

pub fn source_offset(&self) -> usize

Offset of the character index from within the first token of Self::pointer_offset)

"/foo/invalid~tilde/invalid"
             ↑
             8
let err = PointerBuf::parse("/foo/invalid~tilde/invalid").unwrap_err();
assert_eq!(err.source_offset(), 8)
Source

pub fn complete_offset(&self) -> usize

Offset of the first invalid encoding from within the pointer.

"/foo/invalid~tilde/invalid"
             ↑
            12
use jsonptr::PointerBuf;
let err = PointerBuf::parse("/foo/invalid~tilde/invalid").unwrap_err();
assert_eq!(err.complete_offset(), 12)

Trait Implementations§

Source§

impl Debug for ParseError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Diagnostic for ParseError

Source§

type Subject = String

The value which caused the error.
Source§

fn url() -> &'static str

The docs.rs URL for this error
Source§

fn labels( &self, subject: &Self::Subject, ) -> Option<Box<dyn Iterator<Item = Label>>>

Returns the label for the given [Subject] if applicable.
Source§

fn into_report(self, subject: impl Into<Self::Subject>) -> Report<Self>

Combine the error with its subject to generate a Report.
Source§

impl Display for ParseError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for ParseError

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl PartialEq for ParseError

Source§

fn eq(&self, other: &ParseError) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for ParseError

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.