New EventCode API #32
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previous versions of the
EventCode
API had two problems:The conversion from
MessageHeader
→EventCode
was fallible, even though messages with unrecognized event codes should still be played.Since each SAME event code was its own
EventCode
, it was not possible to separate the phenomenon from the severity.This PR is a major overhaul of all enums used to decode SAME event codes.
Originator
Improved detection of National Weather Service vs Environment Canada. The
WeatherService
enum variant is dropped.Rename
Originator::as_str()
toOriginator::as_code_str()
for claritySupport the "alternate" format code.
Originator is no longer
From<&str>
. Instead, it should be constructed viaOriginator::from_org_and_call()
.SignificanceLevel
SignificanceLevel::from()
constructs directly from significance code str. The conversion is now infallible.A new
SignificanceLevel::Unknown
variant is returned when a significance level cannot be determined. It sorts higher thanWarning
.The UnknownSignificanceLevel is no longer required and is removed.
Renamed
SignificanceLevel::as_str()
→SignificanceLevel::as_code_str()
. This method returns a one-character significance code.The following messages are upgraded to
Statement
:Phenomenon
The enum of all the SAME events is renamed to
Phenomenon
.Phenomenon previously de-normalized into significance levels, like
TornadoWatch
andTornadoWarning
, are represented as a single enum entry likeTornado
.Phenomenon from the 2022 revision of NWSI 10-1712 and more Canadian codes are added:
Add basic categories of Phenomenon
Fix bad code entry for ADR (Administrative Message)
EventCode
The
EventCode
is now a struct which represents the combination of aPhenomenon
and aSignificanceLevel
.EventCode
no longer convert directly to static str. Formatting requires eitherDisplay
orto_string()
. The human-readable string output for each SAME event code is largely unchanged. RemoveEventCode::as_display_str()
and replace withas_display_string()
.The alternate formatter for
EventCode
now displays only the phenomenon, likeTornado
, without the significance levelEventCode
are now Ord by their significance levelsEventCode
no longer convert back to their original SAME event code string. UseMessageHeader::event_str()
instead.This is an API-BREAKING change.