aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/output/mod.rs14
-rw-r--r--src/output/pipeline.rs16
2 files changed, 17 insertions, 13 deletions
diff --git a/src/output/mod.rs b/src/output/mod.rs
index 84ed0a4..aadcbf9 100644
--- a/src/output/mod.rs
+++ b/src/output/mod.rs
@@ -8,18 +8,20 @@ pub mod pipeline;
pub use self::pipeline::Pipeline;
+use self::formats::Format;
/// Build an pipeline for the given command line options.
pub fn build_pipeline(opt: &Opt) -> Pipeline {
let stream = io::stdout();
let aggregator = aggregators::WriteThrough;
- if opt.file_name_only {
- Pipeline::new(stream, formats::FileOnly, aggregator)
+ let format: Box<dyn Format> = if opt.file_name_only {
+ Box::new(formats::FileOnly)
} else {
- let format = formats::HumanReadable {
+ Box::new(formats::HumanReadable {
show_guilds: opt.guilds,
- };
- Pipeline::new(stream, format, aggregator)
- }
+ })
+ };
+
+ Pipeline::new(Box::new(stream), format, Box::new(aggregator))
}
diff --git a/src/output/pipeline.rs b/src/output/pipeline.rs
index fb23a6f..9664928 100644
--- a/src/output/pipeline.rs
+++ b/src/output/pipeline.rs
@@ -1,22 +1,24 @@
-use super::{formats::Format, aggregators::Aggregator};
use super::super::LogResult;
+use super::{aggregators::Aggregator, formats::Format};
use std::{io::Write, sync::Mutex};
-
pub struct Pipeline {
format: Box<dyn Format>,
aggregator: Box<dyn Aggregator>,
writer: Mutex<Box<dyn Write + Send>>,
}
-
impl Pipeline {
- pub fn new<W: Write + 'static + Send, F: Format + 'static, A: Aggregator + 'static>(writer: W, format: F, aggregator: A) -> Pipeline {
+ pub fn new(
+ writer: Box<dyn Write + Send>,
+ format: Box<dyn Format>,
+ aggregator: Box<dyn Aggregator>,
+ ) -> Pipeline {
Pipeline {
- format: Box::new(format),
- aggregator: Box::new(aggregator),
- writer: Mutex::new(Box::new(writer)),
+ format,
+ aggregator,
+ writer: Mutex::new(writer),
}
}