[][src]Struct tweep::Warning

pub struct Warning {
    pub kind: WarningKind,
    pub context: Option<Context>,
    pub referent: Option<Context>,
}

A warning with a WarningKind, Position, and optionally a reference to another Position

Examples

use tweep::{FullContext, Warning, WarningKind};
let warning = Warning::new(WarningKind::DuplicateStoryTitle, Some(context))
    .with_referent(referent);

Fields

kind: WarningKind

The warning type

context: Option<Context>

The context of this Warning

referent: Option<Context>

The location referenced by this warning

Implementations

impl Warning[src]

pub fn new<T: Into<Context>>(kind: WarningKind, context: Option<T>) -> Self[src]

Creates a new Warning with a default Position and no referent

Examples

use tweep::{FullContext, Warning, WarningKind};
let warning = Warning::new(WarningKind::MissingStartPassage, Some(context));

pub fn has_referent(&self) -> bool[src]

Returns true if this Warning has a referent

Examples

use tweep::{FullContext, Warning, WarningKind};
let mut warning = Warning::new(WarningKind::UnclosedLink, Some(context));
assert!(!warning.has_referent());
warning.set_referent(referent);
assert!(warning.has_referent());

pub fn get_referent(&self) -> Option<&Context>[src]

Gets the referent if one exists

Examples

let warning = Warning::new(WarningKind::DuplicateStoryTitle, Some(context))
    .with_referent(referent.clone());
assert_eq!(warning.get_referent(), Some(&referent));

pub fn set_referent<T: Into<Context>>(&mut self, referent: T)[src]

Sets the referent to the given Position

Examples

let mut warning = Warning::new(WarningKind::DuplicateStoryTitle, Some(context));
warning.set_referent(referent.clone());
assert_eq!(warning.get_referent(), Some(&referent));

pub fn with_referent<T: Into<Context>>(self, referent: T) -> Self[src]

Moves the object, sets the referent to the given Position, and returns the modified object

Examples

let warning = Warning::new(WarningKind::DuplicateStoryTitle, Some(context))
    .with_referent(referent.clone());
assert_eq!(warning.get_referent(), Some(&referent));

Trait Implementations

impl Clone for Warning[src]

impl Debug for Warning[src]

impl Display for Warning[src]

impl Eq for Warning[src]

impl PartialEq<Warning> for Warning[src]

impl StructuralEq for Warning[src]

impl StructuralPartialEq for Warning[src]

Auto Trait Implementations

impl RefUnwindSafe for Warning

impl Send for Warning

impl Sync for Warning

impl Unpin for Warning

impl UnwindSafe for Warning

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.