pub struct Author { /* private fields */ }
Expand description
The author or creator of the message.
The base author will contain the hostname of the OS that sent to message. This helps identify which machine the message came from. If this is not available then ‘?’ will be used.
A good author should allow the user to quickly and easily identify where the message originates from. To make a good author, think, could you quickly and easily stop the source of the messages just based on the author?
Filtering should not be performed based on an Author, rather you should filter instead
based on Level
and Component
Implementations§
Source§impl Author
impl Author
Sourcepub fn parse(parts: String) -> Author
pub fn parse(parts: String) -> Author
Parses an Author from the given string.
// A good Author for a message originating from the db_checker program
// which is invoked by user's crontab.
use rnotifylib::message::author::Author;
let author = Author::parse("user/cron/db_checker".to_owned());
Sourcepub fn base() -> Author
pub fn base() -> Author
Provides the base Author, of either the hostname.
If the hostname cannot be found, uses base_incognito
Sourcepub fn base_incognito() -> Author
pub fn base_incognito() -> Author
Creates an Author with an unknown hostname.
You should use base
whenever possible, but if you do not want to expose
the hostname of the sender, you can use this method.
Sourcepub fn parse_incognito(s: String) -> Author
pub fn parse_incognito(s: String) -> Author
Parses an author, using an unknown hostname
You should use parse
whenever possible, but if you do not want to expose
the hostname of the sender, you can use this method.
Sourcepub fn extend(&mut self, parts: String)
pub fn extend(&mut self, parts: String)
Adds more information to the author of this
use rnotifylib::message::author::Author;
// Normally you should use Author::base(), but we want predictable output for this test.
let mut author = Author::base_incognito();
author.extend("user".to_owned());
author.extend("cron".to_owned());
author.extend("db_checker".to_owned());
assert_eq!(author.to_string(), "?/user/cron/db_checker");