feat: add meta plugin with file and none implementations

This commit is contained in:
Andrew Phillips (aider)
2025-05-22 09:38:43 -03:00
parent 1fd5ec1988
commit beef2e773e
3 changed files with 208 additions and 0 deletions

43
src/meta_plugin/none.rs Normal file
View 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(())
}
}