Struct marked_yaml::FromNodeError

source ·
pub struct FromNodeError { /* private fields */ }
Available on crate feature serde only.
Expand description

The error returned by from_node

From here you can get the logical path to the error if one is available, and then via the error: the marker indicating where the error occurred if it’s available. Finally you may extract the error itself.

Implementations§

source§

impl FromNodeError

source

pub fn path(&self) -> Option<&str>

Available on crate feature serde-path only.

The logical path representing where the error occurred.

Note: this likely will only ever be Some(value) if you enable the serde-path feature, though the function itself will be available with the serde feature.

source

pub fn into_inner(self) -> Error

Extract the inner error

Methods from Deref<Target = Error>§

source

pub fn start_mark(&self) -> Option<Marker>

Retrieve the start marker if there is one

Most spans which are generated by the loader only have start marks (containers have end marks as well, but these failures) are unlikely to exist here.

const YAML: &str = r#"
bad: float
"#;

#[derive(Deserialize)]
struct Example {
    bad: Spanned<f64>,
}

let nodes = parse_yaml(0, YAML).unwrap();
let err = from_node::<Example>(&nodes).err().unwrap();

assert!(matches!(&*err, Error::FloatParseFailure(_,_)));

let mark = err.start_mark().unwrap();

assert_eq!(mark.source(), 0);
assert_eq!(mark.line(), 2);
assert_eq!(mark.column(), 6);

Trait Implementations§

source§

impl Debug for FromNodeError

source§

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

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

impl Deref for FromNodeError

§

type Target = Error

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl Display for FromNodeError

source§

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

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

impl From<FromNodeError> for FromYamlError

source§

fn from(value: FromNodeError) -> Self

Converts to this type from the input type.

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§

default 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>,

§

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>,

§

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.