#[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.
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
impl SignificanceLevel
Sourcepub fn from<S>(code: S) -> SignificanceLevel
pub fn from<S>(code: S) -> SignificanceLevel
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.
Sourcepub fn as_display_str(&self) -> &'static str
pub fn as_display_str(&self) -> &'static str
Human-readable string representation
Converts to a human-readable string, like “Warning.”
Sourcepub fn as_code_str(&self) -> &'static str
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
impl AsRef<str> for SignificanceLevel
Source§impl Clone for SignificanceLevel
impl Clone for SignificanceLevel
Source§fn clone(&self) -> SignificanceLevel
fn clone(&self) -> SignificanceLevel
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SignificanceLevel
impl Debug for SignificanceLevel
Source§impl Default for SignificanceLevel
impl Default for SignificanceLevel
Source§fn default() -> SignificanceLevel
fn default() -> SignificanceLevel
Source§impl Display for SignificanceLevel
impl Display for SignificanceLevel
Source§impl EnumMessage for SignificanceLevel
impl EnumMessage for SignificanceLevel
fn get_message(&self) -> Option<&'static str>
fn get_detailed_message(&self) -> Option<&'static str>
Source§fn get_documentation(&self) -> Option<&'static str>
fn get_documentation(&self) -> Option<&'static str>
fn get_serializations(&self) -> &'static [&'static str]
Source§impl From<&str> for SignificanceLevel
impl From<&str> for SignificanceLevel
Source§fn from(s: &str) -> SignificanceLevel
fn from(s: &str) -> SignificanceLevel
Source§impl Hash for SignificanceLevel
impl Hash for SignificanceLevel
Source§impl IntoEnumIterator for SignificanceLevel
impl IntoEnumIterator for SignificanceLevel
Source§impl Ord for SignificanceLevel
impl Ord for SignificanceLevel
Source§fn cmp(&self, other: &SignificanceLevel) -> Ordering
fn cmp(&self, other: &SignificanceLevel) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for SignificanceLevel
impl PartialEq for SignificanceLevel
Source§impl PartialOrd for SignificanceLevel
impl PartialOrd for SignificanceLevel
impl Copy for SignificanceLevel
impl Eq for SignificanceLevel
impl StructuralPartialEq for SignificanceLevel
Auto Trait Implementations§
impl Freeze for SignificanceLevel
impl RefUnwindSafe for SignificanceLevel
impl Send for SignificanceLevel
impl Sync for SignificanceLevel
impl Unpin for SignificanceLevel
impl UnwindSafe for SignificanceLevel
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.