refactor: update meta plugins to use new trait interface
Co-authored-by: aider (openai/andrew/openrouter/mistralai/mistral-medium-3.1) <aider@aider.chat>
This commit is contained in:
@@ -160,11 +160,11 @@ impl MetaPlugin for ReadTimeMetaPlugin {
|
||||
true
|
||||
}
|
||||
|
||||
fn finalize(&mut self, _conn: &Connection) -> Result<()> {
|
||||
Ok(())
|
||||
fn finalize(&mut self) -> Result<PluginResponse> {
|
||||
Ok(PluginResponse::default())
|
||||
}
|
||||
|
||||
fn update(&mut self, _data: &[u8], _conn: &Connection) {
|
||||
fn update(&mut self, _data: &[u8]) -> Result<PluginResponse> {
|
||||
if self.start_time.is_none() {
|
||||
self.start_time = Some(Instant::now());
|
||||
}
|
||||
@@ -251,16 +251,37 @@ impl MetaPlugin for ReadRateMetaPlugin {
|
||||
fn is_internal(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn finalize(&mut self, _conn: &Connection) -> Result<()> {
|
||||
Ok(())
|
||||
|
||||
fn finalize(&mut self) -> Result<PluginResponse> {
|
||||
let mut metadata = Vec::new();
|
||||
|
||||
if let Some(start_time) = self.start_time {
|
||||
if let Some(item_id) = self.item_id {
|
||||
let duration = start_time.elapsed();
|
||||
let rate = if duration.as_secs_f64() > 0.0 {
|
||||
format!("{:.2} KB/s", (self.bytes_read as f64 / 1024.0) / duration.as_secs_f64())
|
||||
} else {
|
||||
"N/A".to_string()
|
||||
};
|
||||
|
||||
if let Some(meta) = self.create_meta(item_id, "read_rate", rate) {
|
||||
metadata.push(meta);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(PluginResponse {
|
||||
metadata: Some(metadata),
|
||||
is_finalized: true,
|
||||
})
|
||||
}
|
||||
|
||||
fn update(&mut self, data: &[u8], _conn: &Connection) {
|
||||
fn update(&mut self, data: &[u8]) -> Result<PluginResponse> {
|
||||
if self.start_time.is_none() {
|
||||
self.start_time = Some(Instant::now());
|
||||
}
|
||||
self.bytes_read += data.len() as u64;
|
||||
Ok(PluginResponse::default())
|
||||
}
|
||||
|
||||
fn meta_name(&self) -> String {
|
||||
|
||||
Reference in New Issue
Block a user