use crate::errors::CoreError;
use crate::model::{Bookmark, SourceKind};
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Page {
pub items: Vec<Bookmark>,
pub next_cursor: Option<String>,
}
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct WriteReport {
pub written: usize,
pub failed: Vec<FailedRecord>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FailedRecord {
pub id: String,
pub reason: String,
}
pub trait BookmarkSource: Send + Sync {
fn kind(&self) -> SourceKind;
fn list(&self) -> Result<Vec<Bookmark>, CoreError>;
fn list_paginated(&self, cursor: Option<String>, limit: usize) -> Result<Page, CoreError>;
fn by_canonical(&self, canonical: &str) -> Result<Option<Bookmark>, CoreError>;
}
pub trait BookmarkSink: Send + Sync {
fn kind(&self) -> SourceKind;
fn write(&mut self, bookmarks: &[Bookmark]) -> Result<WriteReport, CoreError>;
fn delete(&mut self, external_id: &str) -> Result<(), CoreError>;
}