pub trait OutputSink: Send + Sync {
// Required method
fn write_message(&mut self, message: &dyn OutputMessage, formatted: &str);
}Expand description
Trait for output destinations
An output sink receives formatted messages and writes them to a destination. Sinks handle the mechanics of where output goes, not how it’s formatted.
§Design Philosophy
Sinks receive already-formatted messages (with theme applied) and route them to appropriate destinations. They don’t handle formatting or verbosity filtering - those concerns are handled by message types and filters respectively.
§Examples
ⓘ
use torrust_tracker_deployer_lib::presentation::cli::views::{OutputSink, OutputMessage};
use std::fs::File;
struct FileSink {
file: File,
}
impl OutputSink for FileSink {
fn write_message(&mut self, message: &dyn OutputMessage, formatted: &str) {
use std::io::Write;
writeln!(self.file, "{}", formatted).ok();
}
}Required Methods§
Sourcefn write_message(&mut self, message: &dyn OutputMessage, formatted: &str)
fn write_message(&mut self, message: &dyn OutputMessage, formatted: &str)
Write a formatted message to this sink
§Arguments
message- The message object (for metadata like channel)formatted- The already-formatted message text
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".