SignificanceLevel

Enum SignificanceLevel 

Source
#[repr(u8)]
pub enum SignificanceLevel { Test = 0, Statement = 1, Emergency = 2, Watch = 3, Warning = 4, Unknown = 5, }
Expand description

SAME message significance level

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

Three-letter SAME codes sometimes use the last letter to indicate significance or severity.

CodeSignificance
xxTtest
xxSstatement
xxEemergency
xxAwatch
xxWwarning

There are many message codes which do not follow this standard—and some even contradict it. sameplace knows the correct significance code for these special cases, and the event API will return it.

Significance codes can be converted directly from or to string.

use sameplace::SignificanceLevel;

assert_eq!(SignificanceLevel::Watch, SignificanceLevel::from("A"));
assert_eq!(SignificanceLevel::Test, SignificanceLevel::from("T"));

assert_eq!("Test", SignificanceLevel::Test.as_display_str());
assert_eq!("Test", format!("{}", SignificanceLevel::Test));
assert_eq!("T", SignificanceLevel::Test.as_code_str());
assert_eq!("T", format!("{:#}", SignificanceLevel::Test));

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);

Unrecognized significance levels are quietly represented as SignificanceLevel::Unknown. Clients are encouraged to treat messages with this significance level as a Warning.

assert_eq!(SignificanceLevel::Unknown, SignificanceLevel::from(""));
assert!(SignificanceLevel::Unknown >= SignificanceLevel::Warning);

Variants§

§

Test = 0

Test

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

§

Statement = 1

Statement

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

§

Emergency = 2

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 = 3

Watch

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

§

Warning = 4

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).

§

Unknown = 5

Unknown significance level

No significance level could be determined, either by knowledge of the complete event code or by examining the last character. Clients are strongly advised to treat unknown-significance messages as SignificanceLevel::Warning.

Implementations§

Source§

impl SignificanceLevel

Source

pub fn from<S>(code: S) -> SignificanceLevel
where S: AsRef<str>,

Parse from string

Parses a SAME significance level from a single-character code like “T” for SignificanceLevel::Test. If the input does not match a significance level, returns SignificanceLevel::Unknown.

The user is cautioned not to blindly convert the last character of a SAME code to a SignificanceLevel. There are many event codes like “EVI” which do not follow the SignificanceLevel convention.

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_code_str(&self) -> &'static str

SAME string representation

Returns the one-character SAME code for this SignificanceLevel. While this is frequently the last character of the event code, there are almost as many exceptions to this rule as there are codes which follow it.

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 duplicate 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<(), Error>

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

impl Default for SignificanceLevel

Source§

fn default() -> SignificanceLevel

Returns the “default value” for a type. Read more
Source§

impl Display for SignificanceLevel

Source§

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

Printable string

  • The normal form is a human-readable string like “Statement
  • The alternate form is a one-character string like “S
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_documentation(&self) -> Option<&'static str>

Get the doc comment associated with a variant if it exists.
Source§

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

Source§

impl From<&str> for SignificanceLevel

Source§

fn from(s: &str) -> SignificanceLevel

Converts to this type from the input type.
Source§

impl Hash for SignificanceLevel

Source§

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

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 IntoEnumIterator for SignificanceLevel

Source§

type Iterator = SignificanceLevelIter

Source§

fn iter() -> SignificanceLevelIter

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) -> 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 SignificanceLevel

Source§

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

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 Copy for SignificanceLevel

Source§

impl Eq for SignificanceLevel

Source§

impl StructuralPartialEq for SignificanceLevel

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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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

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

fn is_in_subset(&self) -> bool

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

fn to_subset_unchecked(&self) -> SS

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

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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> Scalar for T
where T: 'static + Clone + PartialEq + Debug,