Enum sameold::EventCode

source ·
#[non_exhaustive]
#[repr(u8)]
pub enum EventCode {
Show 56 variants EmergencyActionNotification, NationalInformationCenter, NationalPeriodicTest, RequiredMonthlyTest, RequiredWeeklyTest, AdministrativeMessage, AvalancheWatch, AvalancheWarning, BlizzardWarning, BlueAlert, ChildAbductionEmergency, CivilDangerWarning, CivilEmergencyMessage, CoastalFloodWarning, CoastalFloodWatch, DustStormWarning, EarthquakeWarning, EvacuationImmediate, ExtremeWindWarning, FireWarning, FlashFloodWarning, FlashFloodWatch, FlashFloodStatement, FloodWarning, FloodWatch, FloodStatement, HazardousMaterialsWarning, HighWindWarning, HighWindWatch, HurricaneWarning, HurricaneWatch, HurricaneStatement, LawEnforcementWarning, LocalAreaEmergency, NetworkMessageNotification, TelephoneOutageEmergency, NuclearPowerPlantWarning, PracticeDemoWarning, RadiologicalHazardWarning, SevereThunderstormWarning, SevereThunderstormWatch, SevereWeatherStatement, ShelterInPlaceWarning, SpecialMarineWarning, SpecialWeatherStatement, StormSurgeWatch, StormSurgeWarning, TornadoWarning, TornadoWatch, TropicalStormWarning, TropicalStormWatch, TsunamiWarning, TsunamiWatch, VolcanoWarning, WinterStormWarning, WinterStormWatch,
}
Expand description

SAME message event code

Usually constructed via MessageHeader::event(). Event codes were obtained from https://docs.fcc.gov/public/attachments/FCC-16-80A1.pdf.

Converting to string via .as_ref() will yield the SAME event code string. You can also obtain a human-readable message

use sameold::EventCode;

assert_eq!("RWT", (EventCode::RequiredWeeklyTest).as_ref());
assert_eq!("Required Weekly Test", (EventCode::RequiredWeeklyTest).as_display_str());
assert_eq!(
    "Required Weekly Test",
    format!("{}", EventCode::RequiredWeeklyTest)
);

All events are mapped to a significance level. This may be useful when deciding how to handle the event.


let lvl = (EventCode::RequiredWeeklyTest).to_significance_level();
assert_eq!(lvl, SignificanceLevel::Test);

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

EmergencyActionNotification

Emergency Action Notification (begins national activation)

§

NationalInformationCenter

National Information Center (part of national activation)

§

NationalPeriodicTest

National Periodic Test

§

RequiredMonthlyTest

Required Monthly Test

§

RequiredWeeklyTest

Required Weekly Test

§

AdministrativeMessage

Administrative Message (state/local)

§

AvalancheWatch

Avalanche Watch

§

AvalancheWarning

Avalanche Warning

§

BlizzardWarning

Blizzard Warning

§

BlueAlert

Blue Alert (state/local)

§

ChildAbductionEmergency

Child Abduction Emergency (state/local)

§

CivilDangerWarning

Civil Danger Warning (state/local)

§

CivilEmergencyMessage

Civil Emergency Message (state/local)

§

CoastalFloodWarning

Coastal Flood Warning

§

CoastalFloodWatch

Coastal Flood Warning

§

DustStormWarning

Dust Storm Warning

§

EarthquakeWarning

Earthquake Warning

§

EvacuationImmediate

Evacuation Immediate

§

ExtremeWindWarning

Extreme Wind Warning

§

FireWarning

Fire Warning

§

FlashFloodWarning

Flash Flood Warning

§

FlashFloodWatch

Flash Flood Watch

§

FlashFloodStatement

Flash Flood Statement

§

FloodWarning

Flood Warning

§

FloodWatch

Flood Watch

§

FloodStatement

Flood Statement

§

HazardousMaterialsWarning

Hazardous Materials Warning

§

HighWindWarning

High Wind Warning

§

HighWindWatch

High Wind Watch

§

HurricaneWarning

Hurricane Warning

§

HurricaneWatch

Hurricane Watch

§

HurricaneStatement

Hurricane Statement

§

LawEnforcementWarning

Law Enforcement Warning

§

LocalAreaEmergency

Local Area Emergency

§

NetworkMessageNotification

Network Message Notification

§

TelephoneOutageEmergency

911 Telephone Outage Emergency

§

NuclearPowerPlantWarning

Nuclear Power Plant Warning

§

PracticeDemoWarning

Practice/Demo Warning

§

RadiologicalHazardWarning

Radiological Hazard Warning

§

SevereThunderstormWarning

Severe Thunderstorm Warning

§

SevereThunderstormWatch

Severe Thunderstorm Watch

§

SevereWeatherStatement

Severe Weather Statement

§

ShelterInPlaceWarning

Shelter In Place Warning

§

SpecialMarineWarning

Special Marine Warning

§

SpecialWeatherStatement

Special Weather Statement

§

StormSurgeWatch

Storm Surge Watch

§

StormSurgeWarning

Storm Surge Warning

§

TornadoWarning

Tornado Warning

§

TornadoWatch

Tornado Watch

§

TropicalStormWarning

Tropical Storm Warning

§

TropicalStormWatch

Tropical Storm Watch

§

TsunamiWarning

Tsunami Warning

§

TsunamiWatch

Tsunami Watch

§

VolcanoWarning

Volcano Warning

§

WinterStormWarning

Winter Storm Warning

§

WinterStormWatch

Winter Storm Warning

Implementations§

source§

impl EventCode

source

pub fn to_significance_level(&self) -> SignificanceLevel

Obtain event’s significance level

The significance level ranges from “Test” (i.e., “this is only a test”) to “Warning.” Each event code has a significance level associated with it. The SignificanceLevel is useful for determining whether an event merits a “noisy” and/or “immediate” alert for the message.

source

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

Human-readable string representation

Converts to a human-readable string, like “Required Monthly Test.”

source

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

SAME string representation

Returns the three-character SAME code for this EventCode.

Trait Implementations§

source§

impl AsRef<str> for EventCode

source§

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

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

impl Clone for EventCode

source§

fn clone(&self) -> EventCode

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 EventCode

source§

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

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

impl Display for EventCode

source§

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

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

impl EnumMessage for EventCode

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 EnumProperty for EventCode

source§

fn get_str(&self, prop: &str) -> Option<&'static str>

source§

fn get_int(&self, _prop: &str) -> Option<usize>

source§

fn get_bool(&self, _prop: &str) -> Option<bool>

source§

impl<'_derivative_strum> From<&'_derivative_strum EventCode> for &'static str

source§

fn from(x: &'_derivative_strum EventCode) -> &'static str

Converts to this type from the input type.
source§

impl From<&EventCode> for SignificanceLevel

source§

fn from(evt: &EventCode) -> SignificanceLevel

Convert to significance level

source§

impl From<EventCode> for &'static str

source§

fn from(x: EventCode) -> &'static str

Converts to this type from the input type.
source§

impl FromStr for EventCode

§

type Err = ParseError

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

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

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

impl Hash for EventCode

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

source§

impl PartialEq<EventCode> for EventCode

source§

fn eq(&self, other: &EventCode) -> 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 TryFrom<&str> for EventCode

source§

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

Convert from three-character SAME event code

Converts an event code like “SVR” into its enumerated type (EventCode::SevereThunderstormWarning).

If the code is unrecognized, an error is returned. An error here does NOT mean that the message is invalid or should be discarded. Instead, if the error is WithSignificance, then you should treat it as a valid (but unknown) message at the given significance level. This will help your application react correctly if new codes are added in the future.

§

type Error = UnrecognizedEventCode

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

impl Copy for EventCode

source§

impl Eq for EventCode

source§

impl StructuralEq for EventCode

source§

impl StructuralPartialEq for EventCode

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.