fix: resolve ownership and borrowing errors and add serde traits

Co-authored-by: aider (openai/andrew/openrouter/google/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
Andrew Phillips
2025-08-25 13:06:54 -03:00
parent 53c63360cb
commit ee0545b739
7 changed files with 19 additions and 15 deletions

View File

@@ -74,7 +74,7 @@ fn show_item(
let item = item_with_meta.item;
let item_id = item.id.unwrap();
let item_tags: Vec<String> = item_with_meta.tags.into_iter().map(|t| t.name).collect();
let item_tags: Vec<String> = item_with_meta.tags.iter().map(|t| t.name.clone()).collect();
let mut table = Table::new();
if std::io::stdout().is_terminal() {
@@ -156,7 +156,7 @@ fn show_item_structured(
) -> Result<()> {
let item = item_with_meta.item;
let item_id = item.id.unwrap();
let item_tags: Vec<String> = item_with_meta.tags.into_iter().map(|t| t.name).collect();
let item_tags: Vec<String> = item_with_meta.tags.iter().map(|t| t.name.clone()).collect();
let mut item_path_buf = data_path.clone();
item_path_buf.push(item_id.to_string());

View File

@@ -71,7 +71,7 @@ pub fn mode_list(
for item_with_meta in items_with_meta {
let item = item_with_meta.item;
let tags: Vec<String> = item_with_meta.tags.into_iter().map(|t| t.name).collect();
let tags: Vec<String> = item_with_meta.tags.iter().map(|t| t.name.clone()).collect();
let meta = item_with_meta.meta_as_map();
let mut item_path = data_path.clone();
@@ -297,7 +297,7 @@ fn show_list_structured(
for item_with_meta in items_with_meta {
let item = item_with_meta.item;
let item_id = item.id.unwrap();
let tags = item_with_meta.tags.into_iter().map(|t| t.name).collect();
let tags: Vec<String> = item_with_meta.tags.iter().map(|t| t.name.clone()).collect();
let meta = item_with_meta.meta_as_map();
let mut item_path = data_path.clone();

View File

@@ -57,7 +57,7 @@ pub async fn handle_list_items(
// Apply ordering (default is newest first)
match params.order.as_deref().unwrap_or("newest") {
"newest" => items_with_meta.sort_by(|a, b| b.item.ts.cmp(&a.item.ts)),
"oldest" => items_with_meta.sort_by(|a, b| a.item.ts.cmp(&a.item.ts)),
"oldest" => items_with_meta.sort_by(|a, b| a.item.ts.cmp(&b.item.ts)),
_ => items_with_meta.sort_by(|a, b| b.item.ts.cmp(&a.item.ts)), // default to newest
}
@@ -70,7 +70,7 @@ pub async fn handle_list_items(
.into_iter()
.map(|item_with_meta| {
let item_id = item_with_meta.item.id.unwrap_or(0);
let item_tags = item_with_meta.tags.into_iter().map(|t| t.name).collect();
let item_tags: Vec<String> = item_with_meta.tags.iter().map(|t| t.name.clone()).collect();
let item_meta = item_with_meta.meta_as_map();
ItemInfo {

View File

@@ -100,7 +100,7 @@ impl KeepTools {
let item = item_with_content.item_with_meta.item;
let content = String::from_utf8_lossy(&item_with_content.content).to_string();
let tags: Vec<String> = item_with_content.item_with_meta.tags.into_iter().map(|t| t.name).collect();
let tags: Vec<String> = item_with_content.item_with_meta.tags.iter().map(|t| t.name.clone()).collect();
let metadata = item_with_content.item_with_meta.meta_as_map();
let response = serde_json::json!({
@@ -118,6 +118,7 @@ impl KeepTools {
pub async fn get_latest_item(&self, args: Option<Value>) -> Result<String, ToolError> {
let tags: Vec<String> = args
.as_ref()
.and_then(|v| v.get("tags"))
.and_then(|v| v.as_array())
.map(|arr| arr.iter().filter_map(|v| v.as_str().map(|s| s.to_string())).collect())
@@ -136,7 +137,7 @@ impl KeepTools {
let item = item_with_content.item_with_meta.item;
let content = String::from_utf8_lossy(&item_with_content.content).to_string();
let tags: Vec<String> = item_with_content.item_with_meta.tags.into_iter().map(|t| t.name).collect();
let tags: Vec<String> = item_with_content.item_with_meta.tags.iter().map(|t| t.name.clone()).collect();
let metadata = item_with_content.item_with_meta.meta_as_map();
let response = serde_json::json!({
@@ -182,7 +183,7 @@ impl KeepTools {
.map(|item_with_meta| {
let item = item_with_meta.item;
let item_id = item.id.unwrap_or(0);
let item_tags: Vec<String> = item_with_meta.tags.into_iter().map(|t| t.name).collect();
let item_tags: Vec<String> = item_with_meta.tags.iter().map(|t| t.name.clone()).collect();
let item_meta = item_with_meta.meta_as_map();
serde_json::json!({
@@ -234,7 +235,7 @@ impl KeepTools {
.map(|item_with_meta| {
let item = item_with_meta.item;
let item_id = item.id.unwrap_or(0);
let item_tags: Vec<String> = item_with_meta.tags.into_iter().map(|t| t.name).collect();
let item_tags: Vec<String> = item_with_meta.tags.iter().map(|t| t.name.clone()).collect();
let item_meta = item_with_meta.meta_as_map();
serde_json::json!({