MessageImpl

Trait MessageImpl 

Source
pub trait MessageImpl:
    Send
    + Sync
    + Any {
    // Required methods
    fn level(&self) -> &dyn Display;
    fn content(&self) -> &dyn Display;
    fn instant(&self) -> SystemTime;
    fn as_any(&self) -> &dyn Any;
}
Expand description

A trait for Message implementations that can be formatted and downcast.

This trait is the core of the rust_timber extensibility. It allows the logger to handle standard text, JSON, or complex Error objects through type erasure.

Required Methods§

Source

fn level(&self) -> &dyn Display

Returns the log level (e.g., “INFO”, “DEBUG”) as a displayable object. Using &dyn Display ensures zero-copy for static string levels.

Source

fn content(&self) -> &dyn Display

Returns the message body content. This allows for deferred formatting of complex types like JSON or Error objects.

Source

fn instant(&self) -> SystemTime

Returns the exact SystemTime when the message was created. Crucial for maintaining chronological order in asynchronous logging.

Source

fn as_any(&self) -> &dyn Any

Returns a reference to self as a dyn Any for downcasting purposes. This allows services to recover the original concrete type if specialized processing is needed.

Implementors§