-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/new_events' into develop
sameold,samedec: New EventCode API Previous versions of the `EventCode` API had two problems: 1. The conversion from `MessageHeader` → `EventCode` was fallible, even though messages with unrecognized event codes should still be played. 2. 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()` to `Originator::as_code_str()` for clarity * Support the "alternate" format code. * Originator is no longer `From<&str>`. Instead, it should be constructed via `Originator::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 than `Warning`. * 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`: * ADR Administrative Message * NMN Network Message Notification Phenomenon: * The enum of all the SAME events is renamed to `Phenomenon`. * Phenomenon previously de-normalized into significance levels, like `TornadoWatch` and `TornadoWarning`, are represented as a single enum entry like `Tornado`. * Add Phenomenon from the 2022 revision of NWSI 10-1712 and more Canadian codes: * EAN: Renamed to National Emergency Message * NAT: National Audible Test * NST: National Silent Test * FSW: Flash Freeze Warning * FZW: Freeze Warning * HLS: Hurricane Local Statement * SQW: Snow Squall Warning * 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 a `Phenomenon` and a `SignificanceLevel`. * `EventCode` no longer convert directly to static str. Formatting requires either `Display` or `to_string()`. The human-readable string output for each SAME event code is largely unchanged. Remove `EventCode::as_display_str()` and replace with `to_display_string()`. * The alternate formatter for `EventCode` now displays only the phenomenon, like `Tornado`, without the significance level * `EventCode` are now Ord by their significance levels * `EventCode` no longer convert back to their original SAME event code string. Use `MessageHeader::event_str()` instead. This is an API-BREAKING change for sameold but preserves the samedec CLI.
- Loading branch information
Showing
15 changed files
with
1,536 additions
and
832 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.