search_hub

at 18c4440 Raw

use chrono::{DateTime, Utc};
use serde::Serialize;

/// A single entry in the local database (bookmark or history).
///
/// Fields map directly to the FTS5 virtual table columns.  The `id` field
/// corresponds to the FTS5 `rowid`, not the `id` content column.
///
/// # Example
///
/// ```rust
/// use search_hub::models::Bookmark;
/// use chrono::Utc;
///
/// let bm = Bookmark {
///     id: 0,
///     title: "Example".into(),
///     url: "https://example.com".into(),
///     description: Some("A sample bookmark".into()),
///     source: "bookmark".into(),
///     content: None,
///     tags: Some("web, tutorial".into()),
///     created_at: Utc::now(),
/// };
/// # let _ = bm;
/// ```
#[derive(Debug, Serialize)]
pub struct Bookmark {
    /// FTS5 rowid (auto-generated on insert; 0 for new entries).
    pub id: i32,
    /// Human-readable page title.
    pub title: String,
    /// The page URL.
    pub url: String,
    /// Optional user-provided description.
    pub description: Option<String>,
    /// Origin of the entry ("bookmark" or "history").
    pub source: String,
    /// Page body converted to Markdown, if fetching succeeded.
    pub content: Option<String>,
    /// Comma-separated auto-assigned tags, if tagging succeeded.
    pub tags: Option<String>,
    /// UTC timestamp of when the entry was stored.
    pub created_at: DateTime<Utc>,
}

/// Re-export of the search engine result type for external search results.
pub use crate::search_engines::ResultEntry as ExternalResult;