Add bookmark metadata updates

This commit is contained in:
2026-05-08 06:03:43 -04:00
parent a236e6a53b
commit 26d0e4346c
4 changed files with 160 additions and 3 deletions
+26
View File
@@ -89,6 +89,28 @@ impl BookmarkEntry {
pub fn added_at(&self) -> SystemTime {
self.added_at
}
pub fn set_collection_name(
&mut self,
collection_name: impl Into<String>,
) -> Result<(), DomainError> {
self.collection_name = non_empty_text("bookmark collection", collection_name.into())?;
Ok(())
}
pub fn set_tags(&mut self, tags: Vec<String>) -> Result<(), DomainError> {
self.tags = normalize_tags(tags)?;
Ok(())
}
pub fn set_note(&mut self, note: impl Into<String>) -> Result<(), DomainError> {
self.note = Some(non_empty_text("bookmark note", note.into())?);
Ok(())
}
pub fn clear_note(&mut self) {
self.note = None;
}
}
fn non_empty_text(field: &'static str, value: String) -> Result<String, DomainError> {
@@ -98,3 +120,7 @@ fn non_empty_text(field: &'static str, value: String) -> Result<String, DomainEr
}
Ok(trimmed.to_string())
}
fn normalize_tags(tags: Vec<String>) -> Result<Vec<String>, DomainError> {
tags.into_iter().map(|tag| non_empty_text("bookmark tag", tag)).collect()
}