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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//! Traits and implementations for exporting UFW logs into various formats.
//!
//! This module provides the interface for exporting UFW logs into a specific format.
//! You can use the built-in exporter or implement the [`Export`] trait to support new format.
//!
//! ## Quick Start
//!
//! ```rust, no_run
//! let logs = ufwlog::UfwLog::from_file("./ufw.log")?;
//! let target = "csv";
//!
//! let exporter: Box<dyn ufwlog::export::Export> = match target {
//! "csv" => Box::new(ufwlog::export::csv::Exporter),
//! _ => unimplemented!(),
//! };
//! // write to stdout
//! let stdout = std::io::stdout();
//! let mut writer = std::io::BufWriter::new(stdout.lock());
//! exporter.export(&logs, &mut writer)?;
//!
//! # Ok::<(), ufwlog::error::Error>(())
//! ```
use crateError;
/// Supported export formats
/// Defines the interface for exporting UFW logs into a specific format.
///
/// # Implementing
///
/// Types that implement this trait should be zero-size structs, as they
/// typically hold no state.