#[repr(u8)]
pub enum SignificanceLevel {
    Test,
    Message,
    Statement,
    Emergency,
    Watch,
    Warning,
}
Expand description

SAME message significance level

Usually constructed as part of an EventCode. See also MessageHeader::event()

Significance levels have a single-character text representation, like “T” for Test. You can attempt to convert from string:

use sameold::{SignificanceLevel, UnknownSignificanceLevel};

assert_eq!(SignificanceLevel::Watch, SignificanceLevel::try_from("zzA").unwrap());
assert_eq!(UnknownSignificanceLevel {}, SignificanceLevel::try_from("").unwrap_err());
assert_eq!(SignificanceLevel::Test, SignificanceLevel::try_from("T").unwrap());

If a multi-character string is given as input, the last character will be used. The last byte must be valid UTF-8. In all situations where a valid SignificanceLevel can’t be constructed, an error is returned.

Significance levels are Ord. Lower significance levels represent less urgent messages, such as tests and statements. Higher significance levels represent more important or urgent messages which may merit a “noisy” notification.


assert!(SignificanceLevel::Test < SignificanceLevel::Warning);
assert!(SignificanceLevel::Watch < SignificanceLevel::Warning);

Variants§

§

Test

Test

A message intended only for testing purposes. “This is only a test.”

§

Message

Message

A non-emergency message

§

Statement

Statement

A message containing follow up information to a warning, watch, or emergency (NWSI 10-1712).

§

Emergency

Emergency

An event that by itself would not kill or injure or do property damage, but indirectly may cause other things to happen that result in a hazard. Example, a major power or telephone loss in a large city alone is not a direct hazard but disruption to other critical services could create a variety of conditions that could directly threaten public safety (NWSI 10-1712).

§

Watch

Watch

Meets the classification of a warning, but either the onset time, probability of occurrence, or location is uncertain (NWSI 10-1712).

§

Warning

Warning (the most severe event)

Those events that alone pose a significant threat to public safety and/or property, probability of occurrence and location is high, and the onset time is relatively short (NWSI 10-1712).

Implementations§

source§

impl SignificanceLevel

source

pub fn as_display_str(&self) -> &'static str

Human-readable string representation

Converts to a human-readable string, like “Warning.”

source

pub fn as_str(&self) -> &'static str

SAME string representation

Returns the one-character SAME code for this SignificanceLevel. While this is usually the last character of the EventCode, there are many exceptions to this rule.

Trait Implementations§

source§

impl AsRef<str> for SignificanceLevel

source§

fn as_ref(&self) -> &'static str

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Clone for SignificanceLevel

source§

fn clone(&self) -> SignificanceLevel

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 SignificanceLevel

source§

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

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

impl Display for SignificanceLevel

source§

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

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

impl EnumMessage for SignificanceLevel

source§

fn get_message(&self) -> Option<&'static str>

source§

fn get_detailed_message(&self) -> Option<&'static str>

source§

fn get_serializations(&self) -> &'static [&'static str]

source§

impl From<&EventCode> for SignificanceLevel

source§

fn from(evt: &EventCode) -> SignificanceLevel

Convert to significance level

source§

impl FromStr for SignificanceLevel

§

type Err = ParseError

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<SignificanceLevel, Self::Err>

Parses a string s to return a value of this type. Read more
source§

impl Hash for SignificanceLevel

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 SignificanceLevel

source§

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

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

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

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

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

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

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

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

impl PartialEq<SignificanceLevel> for SignificanceLevel

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd<SignificanceLevel> for SignificanceLevel

source§

fn partial_cmp(&self, other: &SignificanceLevel) -> 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

This method 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

This method 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

This method 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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl TryFrom<&str> for SignificanceLevel

source§

fn try_from(inp: &str) -> Result<Self, Self::Error>

Convert from string representation

Matches a standard-form EAS event code, such as xxT for Test, and converts it to its enumerated type. If the given string does not end in a significance level, UnknownSignificanceLevel is returned.

§

type Error = UnknownSignificanceLevel

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

impl Copy for SignificanceLevel

source§

impl Eq for SignificanceLevel

source§

impl StructuralEq for SignificanceLevel

source§

impl StructuralPartialEq for SignificanceLevel

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> Scalar for Twhere T: Copy + PartialEq<T> + Debug + Any,

source§

fn inlined_clone(&self) -> T

Performance hack: Clone doesn’t get inlined for Copy types in debug mode, so make it inline anyway.
source§

fn is<T>() -> boolwhere T: Scalar,

Tests if Self the same as the type T Read more
§

impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.