1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use super::*;
use crate::config::Verbosity;
use std::io::Write;
#[derive(Debug)]
pub(crate) struct StdoutEmitter {
verbosity: Verbosity,
}
impl StdoutEmitter {
pub(crate) fn new(verbosity: Verbosity) -> Self {
Self { verbosity }
}
}
impl Emitter for StdoutEmitter {
fn emit_formatted_file(
&mut self,
output: &mut dyn Write,
FormattedFile {
filename,
formatted_text,
..
}: FormattedFile<'_>,
) -> Result<EmitterResult, io::Error> {
if self.verbosity != Verbosity::Quiet {
writeln!(output, "{}:\n", filename)?;
}
write!(output, "{}", formatted_text)?;
Ok(EmitterResult::default())
}
}