Trait conciliator::Conciliator
source · pub trait Conciliator: for<'l> GetLine<'l> {
// Provided methods
fn line<I: InitialContent>(&self, init: I) -> <Self as GetLine<'_>>::Line { ... }
fn status<I: InitialContent>(&self, init: I) -> <Self as GetLine<'_>>::Line { ... }
fn info<I: InitialContent>(&self, init: I) -> <Self as GetLine<'_>>::Line { ... }
fn warn<I: InitialContent>(&self, init: I) -> <Self as GetLine<'_>>::Line { ... }
fn error<I: InitialContent>(&self, init: I) -> <Self as GetLine<'_>>::Line { ... }
fn print<T: Print>(&self, thing: T) { ... }
}
Expand description
[ > ]
Decorate user-facing messages with tags
This trait extends GetLine
implementers to decorate messages with a tag like [ > ]
.
There are four different tags and they can be used to categorize output messages similar to a log level.
In this regard, they can be used to highlight warning and error messages visually, but there is no filtering / severity threshold (or any of the functionality which a logging library might provide): the tags are entirely decorative.
It could be argued that there is some utility in visually highlighting warning and error messages, but the main motivation is aesthetic – to get a slightly more polished and intentional look than what you’d get using bare println!
s.
It adds a little bit of “structure” to the output & makes certain messages stand out without having to resort to ALL CAPS or drawing boxes with @@@@@@@@@@
and =============
.
Whether it achieves that is obviously a matter of personal taste, and to some extent this really is just needless ceremony.
With that said, using the Conciliator
over println!
does encourage a certain degree of discipline around writing to stdout, which is a globally shared resource.
Instead of having access to it directly from anywhere in the program, a struct (i.e. the Claw
) is instantiated once and then passed around explicitly.
Additionally, it offers the user an opportunity to customize the appearance of the application, as described in the style
module-level docs.
Provided Methods§
sourcefn line<I: InitialContent>(&self, init: I) -> <Self as GetLine<'_>>::Line
fn line<I: InitialContent>(&self, init: I) -> <Self as GetLine<'_>>::Line
Get a plain buffer without a tag
sourcefn status<I: InitialContent>(&self, init: I) -> <Self as GetLine<'_>>::Line
fn status<I: InitialContent>(&self, init: I) -> <Self as GetLine<'_>>::Line
Get a line buffer with the status tag
sourcefn info<I: InitialContent>(&self, init: I) -> <Self as GetLine<'_>>::Line
fn info<I: InitialContent>(&self, init: I) -> <Self as GetLine<'_>>::Line
Get a line buffer with the info tag
sourcefn warn<I: InitialContent>(&self, init: I) -> <Self as GetLine<'_>>::Line
fn warn<I: InitialContent>(&self, init: I) -> <Self as GetLine<'_>>::Line
Get a line buffer with the warn tag