Closes the #3110 split — lib.rs is now just the crate doc comment and the pub mod list. journal.rs's new doc comment fixes a pre-existing bug: the old JournalPriority doc text in lib.rs was actually half Capability's doc (a leftover from an earlier reorder that moved the code but not the comment above it).
41 lines
1.3 KiB
Rust
41 lines
1.3 KiB
Rust
//! Journal-priority encoding for `GetHostJournal` (`read_host_journal`
|
|
//! capability). One small enum, own topic module rather than a
|
|
//! catch-all — see `hive-sh4re/README.md`'s module list.
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
/// Syslog priority levels for `GetHostJournal`. Serialised as lowercase
|
|
/// strings matching journalctl `-p` accepted values.
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, schemars::JsonSchema)]
|
|
#[serde(rename_all = "lowercase")]
|
|
pub enum JournalPriority {
|
|
Emerg,
|
|
Alert,
|
|
Crit,
|
|
Err,
|
|
Warning,
|
|
Notice,
|
|
Info,
|
|
Debug,
|
|
}
|
|
|
|
impl JournalPriority {
|
|
/// Returns the lowercase string journalctl expects for `-p`. Named
|
|
/// `as_journald_str` (not `as_str`) because this is a specific
|
|
/// external-tool encoding, not the enum's general wire/db string —
|
|
/// distinct call sites shouldn't reach for this by accident when they
|
|
/// actually want the serde wire representation.
|
|
#[must_use]
|
|
pub fn as_journald_str(self) -> &'static str {
|
|
match self {
|
|
Self::Emerg => "emerg",
|
|
Self::Alert => "alert",
|
|
Self::Crit => "crit",
|
|
Self::Err => "err",
|
|
Self::Warning => "warning",
|
|
Self::Notice => "notice",
|
|
Self::Info => "info",
|
|
Self::Debug => "debug",
|
|
}
|
|
}
|
|
}
|