Enum Concern

Source
pub enum Concern {
    LintWarning(Warning),
    ParseError(Error),
    ValidationFailure(Failure),
}
Expand description

A concern.

A concern is defined as any information that is important to interpretting a returned parse or abstract syntax tree. There are three classes of concerns that can be returned:

  • Parse errors, which are errors that are return by Pest during the building of the parse tree.
  • Validation failures, which are error that are occur when validating a parse tree or abstract syntax tree.
  • Lint warnings, which are notifications about syntactically and semantically correct code that is otherwise notable, such as stylistic errors, programming mistakes, or deviations from best practices.

Variants§

§

LintWarning(Warning)

A lint warning.

§

ParseError(Error)

A parse error.

§

ValidationFailure(Failure)

A validation failure.

Implementations§

Source§

impl Concern

Source

pub fn as_lint_warning(&self) -> Option<&Warning>

Returns [Some(&lint::Warning)] if the Concern is a lint::Warning. Otherwise, returns None.

§Examples
use wdl_core::concern::code::Kind;
use wdl_core::concern::lint;
use wdl_core::concern::lint::Level;
use wdl_core::concern::lint::TagSet;
use wdl_core::concern::parse;
use wdl_core::concern::validation;
use wdl_core::concern::Code;
use wdl_core::file::Location;
use wdl_core::Concern;
use wdl_core::Version;

let error = parse::Error::new("Hello, world!", Location::Unplaced);
let concern = Concern::ParseError(error);
assert!(concern.as_lint_warning().is_none());

let failure = validation::failure::Builder::default()
    .code(Code::try_new(Kind::Error, Version::V1, 1)?)
    .push_location(Location::Unplaced)
    .subject("Hello, world!")
    .body("A body.")
    .fix("How to fix the issue.")
    .try_build()?;

let concern = Concern::ValidationFailure(failure);
assert!(concern.as_lint_warning().is_none());

let warning = lint::warning::Builder::default()
    .code(Code::try_new(Kind::Warning, Version::V1, 1)?)
    .level(Level::High)
    .tags(TagSet::new(&[lint::Tag::Style]))
    .push_location(Location::Unplaced)
    .subject("Hello, world!")
    .body("A body.")
    .fix("How to fix the issue.")
    .try_build()?;

let concern = Concern::LintWarning(warning);
assert!(concern.as_lint_warning().is_some());
Source

pub fn into_lint_warning(self) -> Option<Warning>

Consumes self and returns [Some(lint::Warning)] if the Concern is a lint::Warning. Otherwise, returns None.

§Examples
use wdl_core::concern::code::Kind;
use wdl_core::concern::lint;
use wdl_core::concern::lint::Level;
use wdl_core::concern::lint::TagSet;
use wdl_core::concern::parse;
use wdl_core::concern::validation;
use wdl_core::concern::Code;
use wdl_core::file::Location;
use wdl_core::Concern;
use wdl_core::Version;

let error = parse::Error::new("Hello, world!", Location::Unplaced);
let concern = Concern::ParseError(error);
assert!(concern.into_lint_warning().is_none());

let failure = validation::failure::Builder::default()
    .code(Code::try_new(Kind::Error, Version::V1, 1)?)
    .push_location(Location::Unplaced)
    .subject("Hello, world!")
    .body("A body.")
    .fix("How to fix the issue.")
    .try_build()?;

let concern = Concern::ValidationFailure(failure);
assert!(concern.into_lint_warning().is_none());

let warning = lint::warning::Builder::default()
    .code(Code::try_new(Kind::Warning, Version::V1, 1)?)
    .level(Level::High)
    .tags(TagSet::new(&[lint::Tag::Style]))
    .push_location(Location::Unplaced)
    .subject("Hello, world!")
    .body("A body.")
    .fix("How to fix the issue.")
    .try_build()?;

let concern = Concern::LintWarning(warning);
assert!(concern.into_lint_warning().is_some());
Source

pub fn as_validation_failure(&self) -> Option<&Failure>

Returns [Some(&validation::Failure)] if the Concern is a validation::Failure. Otherwise, returns None.

§Examples
use wdl_core::concern::code::Kind;
use wdl_core::concern::lint;
use wdl_core::concern::lint::Level;
use wdl_core::concern::lint::TagSet;
use wdl_core::concern::parse;
use wdl_core::concern::validation;
use wdl_core::concern::Code;
use wdl_core::file::Location;
use wdl_core::Concern;
use wdl_core::Version;

let error = parse::Error::new("Hello, world!", Location::Unplaced);
let concern = Concern::ParseError(error);
assert!(concern.as_validation_failure().is_none());

let failure = validation::failure::Builder::default()
    .code(Code::try_new(Kind::Error, Version::V1, 1)?)
    .push_location(Location::Unplaced)
    .subject("Hello, world!")
    .body("A body.")
    .fix("How to fix the issue.")
    .try_build()?;

let concern = Concern::ValidationFailure(failure);
assert!(concern.as_validation_failure().is_some());

let warning = lint::warning::Builder::default()
    .code(Code::try_new(Kind::Warning, Version::V1, 1)?)
    .level(Level::High)
    .tags(TagSet::new(&[lint::Tag::Style]))
    .push_location(Location::Unplaced)
    .subject("Hello, world!")
    .body("A body.")
    .fix("How to fix the issue.")
    .try_build()?;

let concern = Concern::LintWarning(warning);
assert!(concern.as_validation_failure().is_none());
Source

pub fn into_validation_failure(self) -> Option<Failure>

Consumes self and returns [Some(validation::Failure)] if the Concern is a validation::Failure. Otherwise, returns None.

§Examples
use wdl_core::concern::code::Kind;
use wdl_core::concern::lint;
use wdl_core::concern::lint::Level;
use wdl_core::concern::lint::TagSet;
use wdl_core::concern::parse;
use wdl_core::concern::validation;
use wdl_core::concern::Code;
use wdl_core::file::Location;
use wdl_core::Concern;
use wdl_core::Version;

let error = parse::Error::new("Hello, world!", Location::Unplaced);
let concern = Concern::ParseError(error);
assert!(concern.into_validation_failure().is_none());

let failure = validation::failure::Builder::default()
    .code(Code::try_new(Kind::Error, Version::V1, 1)?)
    .push_location(Location::Unplaced)
    .subject("Hello, world!")
    .body("A body.")
    .fix("How to fix the issue.")
    .try_build()?;

let concern = Concern::ValidationFailure(failure);
assert!(concern.into_validation_failure().is_some());

let warning = lint::warning::Builder::default()
    .code(Code::try_new(Kind::Warning, Version::V1, 1)?)
    .level(Level::High)
    .tags(TagSet::new(&[lint::Tag::Style]))
    .push_location(Location::Unplaced)
    .subject("Hello, world!")
    .body("A body.")
    .fix("How to fix the issue.")
    .try_build()?;

let concern = Concern::LintWarning(warning);
assert!(concern.into_validation_failure().is_none());
Source

pub fn as_parse_error(&self) -> Option<&Error>

Returns [Some(&parse::Error)] if the Concern is a parse::Error. Otherwise, returns None.

§Examples
use wdl_core::concern::code::Kind;
use wdl_core::concern::lint;
use wdl_core::concern::lint::Level;
use wdl_core::concern::lint::TagSet;
use wdl_core::concern::parse;
use wdl_core::concern::validation;
use wdl_core::concern::Code;
use wdl_core::file::Location;
use wdl_core::Concern;
use wdl_core::Version;

let error = parse::Error::new("Hello, world!", Location::Unplaced);
let concern = Concern::ParseError(error);
assert!(concern.as_parse_error().is_some());

let failure = validation::failure::Builder::default()
    .code(Code::try_new(Kind::Error, Version::V1, 1)?)
    .push_location(Location::Unplaced)
    .subject("Hello, world!")
    .body("A body.")
    .fix("How to fix the issue.")
    .try_build()?;

let concern = Concern::ValidationFailure(failure);
assert!(concern.as_parse_error().is_none());

let warning = lint::warning::Builder::default()
    .code(Code::try_new(Kind::Warning, Version::V1, 1)?)
    .level(Level::High)
    .tags(TagSet::new(&[lint::Tag::Style]))
    .push_location(Location::Unplaced)
    .subject("Hello, world!")
    .body("A body.")
    .fix("How to fix the issue.")
    .try_build()?;

let concern = Concern::LintWarning(warning);
assert!(concern.as_parse_error().is_none());
Source

pub fn into_parse_error(self) -> Option<Error>

Consumes self and returns [Some(parse::Error)] if the Concern is a parse::Error. Otherwise, returns None.

§Examples
use wdl_core::concern::code::Kind;
use wdl_core::concern::lint;
use wdl_core::concern::lint::Level;
use wdl_core::concern::lint::TagSet;
use wdl_core::concern::parse;
use wdl_core::concern::validation;
use wdl_core::concern::Code;
use wdl_core::file::Location;
use wdl_core::Concern;
use wdl_core::Version;

let error = parse::Error::new("Hello, world!", Location::Unplaced);
let concern = Concern::ParseError(error);
assert!(concern.into_parse_error().is_some());

let failure = validation::failure::Builder::default()
    .code(Code::try_new(Kind::Error, Version::V1, 1)?)
    .push_location(Location::Unplaced)
    .subject("Hello, world!")
    .body("A body.")
    .fix("How to fix the issue.")
    .try_build()?;

let concern = Concern::ValidationFailure(failure);
assert!(concern.into_parse_error().is_none());

let warning = lint::warning::Builder::default()
    .code(Code::try_new(Kind::Warning, Version::V1, 1)?)
    .level(Level::High)
    .tags(TagSet::new(&[lint::Tag::Style]))
    .push_location(Location::Unplaced)
    .subject("Hello, world!")
    .body("A body.")
    .fix("How to fix the issue.")
    .try_build()?;

let concern = Concern::LintWarning(warning);
assert!(concern.into_parse_error().is_none());

Trait Implementations§

Source§

impl Clone for Concern

Source§

fn clone(&self) -> Concern

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Concern

Source§

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

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

impl<'de> Deserialize<'de> for Concern

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Concern

Source§

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

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

impl Hash for Concern

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Concern

Source§

fn cmp(&self, other: &Concern) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Concern

Source§

fn eq(&self, other: &Concern) -> 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 PartialOrd for Concern

Source§

fn partial_cmp(&self, other: &Concern) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for Concern

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for Concern

Source§

impl StructuralPartialEq for Concern

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,