refactor: standardize plugin implementation using base meta plugin
Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
@@ -45,16 +45,17 @@ impl BinaryMetaPlugin {
|
|||||||
.and_then(|v| v.as_u64())
|
.and_then(|v| v.as_u64())
|
||||||
.unwrap_or(PIPESIZE as u64) as usize;
|
.unwrap_or(PIPESIZE as u64) as usize;
|
||||||
|
|
||||||
|
let mut base = crate::meta_plugin::BaseMetaPlugin::new();
|
||||||
|
base.outputs = final_outputs;
|
||||||
|
base.options = final_options;
|
||||||
|
|
||||||
BinaryMetaPlugin {
|
BinaryMetaPlugin {
|
||||||
meta_name: "binary".to_string(),
|
meta_name: "binary".to_string(),
|
||||||
buffer: Vec::new(),
|
buffer: Vec::new(),
|
||||||
max_buffer_size,
|
max_buffer_size,
|
||||||
is_saved: false,
|
is_saved: false,
|
||||||
item_id: None,
|
item_id: None,
|
||||||
base: crate::meta_plugin::BaseMetaPlugin {
|
base,
|
||||||
outputs: final_outputs,
|
|
||||||
options: final_options,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,10 +146,6 @@ impl MetaPlugin for BinaryMetaPlugin {
|
|||||||
self.base.options_mut()
|
self.base.options_mut()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn options_mut(&mut self) -> &mut std::collections::HashMap<String, serde_yaml::Value> {
|
|
||||||
&mut self.base.options
|
|
||||||
}
|
|
||||||
|
|
||||||
fn configure_options(&mut self, options: &std::collections::HashMap<String, serde_yaml::Value>) -> Result<()> {
|
fn configure_options(&mut self, options: &std::collections::HashMap<String, serde_yaml::Value>) -> Result<()> {
|
||||||
if let Some(max_buffer_size) = options.get("max_buffer_size") {
|
if let Some(max_buffer_size) = options.get("max_buffer_size") {
|
||||||
if let Some(size) = max_buffer_size.as_u64() {
|
if let Some(size) = max_buffer_size.as_u64() {
|
||||||
|
|||||||
@@ -14,8 +14,7 @@ pub struct MagicFileMetaPlugin {
|
|||||||
is_saved: bool,
|
is_saved: bool,
|
||||||
item_id: Option<i64>,
|
item_id: Option<i64>,
|
||||||
cookie: Option<Cookie>,
|
cookie: Option<Cookie>,
|
||||||
outputs: std::collections::HashMap<String, serde_yaml::Value>,
|
base: crate::meta_plugin::BaseMetaPlugin,
|
||||||
options: std::collections::HashMap<String, serde_yaml::Value>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MagicFileMetaPlugin {
|
impl MagicFileMetaPlugin {
|
||||||
@@ -48,14 +47,17 @@ impl MagicFileMetaPlugin {
|
|||||||
.and_then(|v| v.as_u64())
|
.and_then(|v| v.as_u64())
|
||||||
.unwrap_or(PIPESIZE as u64) as usize;
|
.unwrap_or(PIPESIZE as u64) as usize;
|
||||||
|
|
||||||
|
let mut base = crate::meta_plugin::BaseMetaPlugin::new();
|
||||||
|
base.outputs = final_outputs;
|
||||||
|
base.options = final_options;
|
||||||
|
|
||||||
MagicFileMetaPlugin {
|
MagicFileMetaPlugin {
|
||||||
buffer: Vec::new(),
|
buffer: Vec::new(),
|
||||||
max_buffer_size,
|
max_buffer_size,
|
||||||
is_saved: false,
|
is_saved: false,
|
||||||
item_id: None,
|
item_id: None,
|
||||||
cookie: None,
|
cookie: None,
|
||||||
outputs: final_outputs,
|
base,
|
||||||
options: final_options,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,7 +110,7 @@ impl MagicFileMetaPlugin {
|
|||||||
if let Some(meta_data) = crate::meta_plugin::process_metadata_outputs(
|
if let Some(meta_data) = crate::meta_plugin::process_metadata_outputs(
|
||||||
name,
|
name,
|
||||||
result,
|
result,
|
||||||
&self.outputs
|
self.base.outputs()
|
||||||
) {
|
) {
|
||||||
metadata.push(meta_data);
|
metadata.push(meta_data);
|
||||||
}
|
}
|
||||||
@@ -199,11 +201,11 @@ impl MetaPlugin for MagicFileMetaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn outputs(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
|
fn outputs(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
|
||||||
&self.outputs
|
self.base.outputs()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn outputs_mut(&mut self) -> &mut std::collections::HashMap<String, serde_yaml::Value> {
|
fn outputs_mut(&mut self) -> &mut std::collections::HashMap<String, serde_yaml::Value> {
|
||||||
&mut self.outputs
|
self.base.outputs_mut()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default_outputs(&self) -> Vec<String> {
|
fn default_outputs(&self) -> Vec<String> {
|
||||||
@@ -217,11 +219,11 @@ impl MetaPlugin for MagicFileMetaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn options(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
|
fn options(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
|
||||||
&self.options
|
self.base.options()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn options_mut(&mut self) -> &mut std::collections::HashMap<String, serde_yaml::Value> {
|
fn options_mut(&mut self) -> &mut std::collections::HashMap<String, serde_yaml::Value> {
|
||||||
&mut self.options
|
self.base.options_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -91,8 +91,7 @@ impl MetaPlugin for CwdMetaPlugin {
|
|||||||
pub struct UidMetaPlugin {
|
pub struct UidMetaPlugin {
|
||||||
meta_name: String,
|
meta_name: String,
|
||||||
is_saved: bool,
|
is_saved: bool,
|
||||||
outputs: std::collections::HashMap<String, serde_yaml::Value>,
|
base: crate::meta_plugin::BaseMetaPlugin,
|
||||||
options: std::collections::HashMap<String, serde_yaml::Value>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UidMetaPlugin {
|
impl UidMetaPlugin {
|
||||||
@@ -110,7 +109,7 @@ impl UidMetaPlugin {
|
|||||||
|
|
||||||
// Start with default outputs
|
// Start with default outputs
|
||||||
let mut final_outputs = std::collections::HashMap::new();
|
let mut final_outputs = std::collections::HashMap::new();
|
||||||
let default_outputs = Self::default().default_outputs();
|
let default_outputs = vec!["uid".to_string()];
|
||||||
for output_name in default_outputs {
|
for output_name in default_outputs {
|
||||||
final_outputs.insert(output_name.clone(), serde_yaml::Value::String(output_name));
|
final_outputs.insert(output_name.clone(), serde_yaml::Value::String(output_name));
|
||||||
}
|
}
|
||||||
@@ -120,11 +119,14 @@ impl UidMetaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mut base = crate::meta_plugin::BaseMetaPlugin::new();
|
||||||
|
base.outputs = final_outputs;
|
||||||
|
base.options = final_options;
|
||||||
|
|
||||||
UidMetaPlugin {
|
UidMetaPlugin {
|
||||||
meta_name: "uid".to_string(),
|
meta_name: "uid".to_string(),
|
||||||
is_saved: false,
|
is_saved: false,
|
||||||
outputs: final_outputs,
|
base,
|
||||||
options: final_options,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,8 +193,7 @@ impl MetaPlugin for UidMetaPlugin {
|
|||||||
pub struct UserMetaPlugin {
|
pub struct UserMetaPlugin {
|
||||||
meta_name: String,
|
meta_name: String,
|
||||||
is_saved: bool,
|
is_saved: bool,
|
||||||
outputs: std::collections::HashMap<String, serde_yaml::Value>,
|
base: crate::meta_plugin::BaseMetaPlugin,
|
||||||
options: std::collections::HashMap<String, serde_yaml::Value>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UserMetaPlugin {
|
impl UserMetaPlugin {
|
||||||
@@ -210,7 +211,7 @@ impl UserMetaPlugin {
|
|||||||
|
|
||||||
// Start with default outputs
|
// Start with default outputs
|
||||||
let mut final_outputs = std::collections::HashMap::new();
|
let mut final_outputs = std::collections::HashMap::new();
|
||||||
let default_outputs = Self::default().default_outputs();
|
let default_outputs = vec!["user".to_string()];
|
||||||
for output_name in default_outputs {
|
for output_name in default_outputs {
|
||||||
final_outputs.insert(output_name.clone(), serde_yaml::Value::String(output_name));
|
final_outputs.insert(output_name.clone(), serde_yaml::Value::String(output_name));
|
||||||
}
|
}
|
||||||
@@ -220,11 +221,14 @@ impl UserMetaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mut base = crate::meta_plugin::BaseMetaPlugin::new();
|
||||||
|
base.outputs = final_outputs;
|
||||||
|
base.options = final_options;
|
||||||
|
|
||||||
UserMetaPlugin {
|
UserMetaPlugin {
|
||||||
meta_name: "user".to_string(),
|
meta_name: "user".to_string(),
|
||||||
is_saved: false,
|
is_saved: false,
|
||||||
outputs: final_outputs,
|
base,
|
||||||
options: final_options,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,11 +263,11 @@ impl MetaPlugin for UserMetaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn outputs(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
|
fn outputs(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
|
||||||
&self.outputs
|
self.base.outputs()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn outputs_mut(&mut self) -> &mut std::collections::HashMap<String, serde_yaml::Value> {
|
fn outputs_mut(&mut self) -> &mut std::collections::HashMap<String, serde_yaml::Value> {
|
||||||
&mut self.outputs
|
self.base.outputs_mut()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default_outputs(&self) -> Vec<String> {
|
fn default_outputs(&self) -> Vec<String> {
|
||||||
@@ -275,15 +279,11 @@ impl MetaPlugin for UserMetaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn options(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
|
fn options(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
|
||||||
&self.base.options
|
self.base.options()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn options_mut(&mut self) -> &mut std::collections::HashMap<String, serde_yaml::Value> {
|
fn options_mut(&mut self) -> &mut std::collections::HashMap<String, serde_yaml::Value> {
|
||||||
&mut self.base.options
|
self.base.options_mut()
|
||||||
}
|
|
||||||
|
|
||||||
fn options_mut(&mut self) -> &mut std::collections::HashMap<String, serde_yaml::Value> {
|
|
||||||
&mut self.options
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user