pub struct Color { /* private fields */ }Expand description
Represents an RGB color.
Implementations§
Source§impl Color
impl Color
Sourcepub fn new(r: u8, g: u8, b: u8) -> Self
pub fn new(r: u8, g: u8, b: u8) -> Self
Creates a new Color instance with the given RGB values.
§Arguments
r- Red component (0-255)g- Green component (0-255)b- Blue component (0-255)
Examples found in repository?
examples/dlog.rs (line 40)
20fn showcase_log_levels() {
21 println!("\n{}", "Log Levels Demonstration:".style(Style::Bold).style(Style::Italic));
22
23 // Helper function to set log level, print color-coded messages, and log all levels
24 fn demonstrate_log_level(level: Level, color: Color, description: &str) {
25 println!("\n{}", format!("Log Level: {}", description).style(Style::Bold).color(color));
26 set_max_level(level);
27 log_all_levels();
28 }
29
30 // Function to log messages at all levels
31 fn log_all_levels() {
32 trace!("Most detailed level, useful for step-by-step debugging");
33 debug!("Useful for diagnosing issues");
34 info!("General operational messages about program execution");
35 warn!("Something unexpected happened, but the program can still continue");
36 error!("A serious problem occurred, indicating potential a failure");
37 }
38
39 // Demonstrate log levels with different settings
40 demonstrate_log_level(Level::Trace, Color::new(180, 0, 158), "Trace (all levels visible)");
41 demonstrate_log_level(Level::Debug, Color::new( 97, 214, 214), "Debug (Trace hidden, Debug and above visible)");
42 demonstrate_log_level(Level::Info, Color::new( 22, 198, 12), "Info (Trace and Debug hidden, Info and above visible)");
43 demonstrate_log_level(Level::Warn, Color::new(245, 245, 57), "Warn (Only Warn and Error visible)");
44 demonstrate_log_level(Level::Error, Color::new(231, 72, 86), "Error (Only Error logs visible)");
45
46 // Restore Trace level at the end
47 set_max_level(Level::Trace);
48 println!("\n{}", "Log Level restored to Trace.".style(Style::Bold).color(GREEN));
49}Trait Implementations§
impl Copy for Color
impl Eq for Color
impl StructuralPartialEq for Color
Auto Trait Implementations§
impl Freeze for Color
impl RefUnwindSafe for Color
impl Send for Color
impl Sync for Color
impl Unpin for Color
impl UnwindSafe for Color
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more