#[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) -> Self
pub fn from<S>(code: S) -> Self
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 more