feat: add meta plugin with file and none implementations
This commit is contained in:
43
src/meta_plugin/none.rs
Normal file
43
src/meta_plugin/none.rs
Normal file
@@ -0,0 +1,43 @@
|
||||
use anyhow::Result;
|
||||
use log::*;
|
||||
use std::io::{self, Write};
|
||||
|
||||
#[derive(Debug, Eq, PartialEq, Clone, Default)]
|
||||
pub struct MetaPluginNone {}
|
||||
|
||||
impl MetaPluginNone {
|
||||
pub fn new() -> MetaPluginNone {
|
||||
MetaPluginNone {}
|
||||
}
|
||||
}
|
||||
|
||||
impl MetaPlugin for MetaPluginNone {
|
||||
fn create(&self) -> Result<Box<dyn Write>> {
|
||||
Ok(Box::new(DummyWriter::new()))
|
||||
}
|
||||
|
||||
fn finalize(&mut self) -> io::Result<String> {
|
||||
Ok("none".to_string())
|
||||
}
|
||||
|
||||
fn update(&mut self, _data: &[u8]) {}
|
||||
}
|
||||
|
||||
// Dummy writer that implements Write for the none meta plugin
|
||||
struct DummyWriter;
|
||||
|
||||
impl DummyWriter {
|
||||
fn new() -> Self {
|
||||
DummyWriter
|
||||
}
|
||||
}
|
||||
|
||||
impl Write for DummyWriter {
|
||||
fn write(&mut self, _buf: &[u8]) -> io::Result<usize> {
|
||||
Ok(0)
|
||||
}
|
||||
|
||||
fn flush(&mut self) -> io::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user