///|
/// How loudly a surface should present a diagnostic.
///
/// Owned by the event that carries it rather than chosen at the call site, so
/// one condition cannot be reported at two severities by two emitters.
pub(all) enum Severity {
/// Detail a surface may fold away by default.
Debug
/// Normal progress worth showing.
Info
/// Something suspect that did not stop the operation.
Warn
/// The operation failed.
Error
} derive(Eq, Debug)
///|
/// Stable lowercase wire token.
pub fn Severity::token(self : Severity) -> String {
match self {
Debug => "debug"
Info => "info"
Warn => "warn"
Error => "error"
}
}
///|
/// Inverse of `token`; `None` for a token this version does not know.
pub fn Severity::parse(token : String) -> Severity? {
match token {
"debug" => Some(Debug)
"info" => Some(Info)
"warn" => Some(Warn)
"error" => Some(Error)
_ => None
}
}