1 pub(crate) use self::checkstyle::*;
2 pub(crate) use self::diff::*;
3 pub(crate) use self::files::*;
4 pub(crate) use self::files_with_backup::*;
5 pub(crate) use self::json::*;
6 pub(crate) use self::modified_lines::*;
7 pub(crate) use self::stdout::*;
9 use std::io::{self, Write};
15 mod files_with_backup;
20 pub(crate) struct FormattedFile<'a> {
21 pub(crate) filename: &'a FileName,
22 pub(crate) original_text: &'a str,
23 pub(crate) formatted_text: &'a str,
26 #[derive(Debug, Default, Clone)]
27 pub(crate) struct EmitterResult {
28 pub(crate) has_diff: bool,
31 pub(crate) trait Emitter {
32 fn emit_formatted_file(
34 output: &mut dyn Write,
35 formatted_file: FormattedFile<'_>,
36 ) -> Result<EmitterResult, io::Error>;
38 fn emit_header(&self, _output: &mut dyn Write) -> Result<(), io::Error> {
42 fn emit_footer(&self, _output: &mut dyn Write) -> Result<(), io::Error> {
47 fn ensure_real_path(filename: &FileName) -> &Path {
49 FileName::Real(ref path) => path,
50 _ => panic!("cannot format `{}` and emit to files", filename),