Skip to main content

SqlitePaperRepository

Struct SqlitePaperRepository 

Source
pub struct SqlitePaperRepository { /* private fields */ }

Implementations§

Source§

impl SqlitePaperRepository

Source

pub fn new(db: Database) -> Self

Source

pub fn db(&self) -> &Database

Borrow the underlying Database so callers (e.g. the bib-import orchestrator in #157) can drive a multi-repo transaction over a single pooled connection. Read-only access — repos remain the canonical write surface.

Source

pub fn taken_bibtex_keys(&self) -> Result<HashSet<String>, CoreError>

Snapshot of every bibtex_key currently assigned in the DB — used as the taken set when assigning keys to newly-imported papers via scitadel_core::bibtex_key::assign_keys. Mirrors the seed in Database::backfill_bibtex_keys.

Source

pub fn taken_bibtex_keys_in_tx( tx: &Transaction<'_>, ) -> Result<HashSet<String>, CoreError>

Transactional sibling of Self::taken_bibtex_keys (#157). Runs the snapshot inside an in-flight transaction so the bib-import orchestrator’s per-row tx sees its own pending writes.

Source

pub fn save_in_tx(tx: &Transaction<'_>, paper: &Paper) -> Result<(), CoreError>

Transactional sibling of PaperRepository::save (#157). Same upsert + DOI-conflict-retry logic, but runs against the caller’s transaction so a multi-step import operation can roll back as a unit on partial failure.

Source

pub fn update_bibtex_key_in_tx( tx: &Transaction<'_>, paper_id: &str, key: &str, ) -> Result<(), CoreError>

Transactional sibling of PaperRepository::update_bibtex_key (#157).

Source

pub fn find_id_by_arxiv_id( &self, arxiv_id: &str, ) -> Result<Option<String>, CoreError>

Lookup-by-id helpers used by the bib-import matcher (#134). Inherent (not on PaperRepository) so the port surface stays minimal — these are only consumed by the import wiring layer.

Source

pub fn find_id_by_pubmed_id( &self, pubmed_id: &str, ) -> Result<Option<String>, CoreError>

Source

pub fn find_id_by_openalex_id( &self, openalex_id: &str, ) -> Result<Option<String>, CoreError>

Source

pub fn find_id_by_bibtex_key( &self, key: &str, ) -> Result<Option<String>, CoreError>

Source

pub fn find_id_by_title_and_year( &self, title: &str, year: Option<i32>, ) -> Result<Option<String>, CoreError>

Case-insensitive title match, optionally constrained by year. Year None means “any year”. Title comparison uses unicode_lower() (a Rust-side to_lowercase registered as a SQL scalar function in Database::open — see #159) so case folds work for non-ASCII characters like Ü/ü. Whitespace normalization is the caller’s responsibility (the matcher passes title verbatim today — good enough for the issue’s stated “exact match only” intent).

Trait Implementations§

Source§

impl PaperRepository for SqlitePaperRepository

Source§

fn save(&self, paper: &Paper) -> Result<(), CoreError>

Source§

fn save_many( &self, papers: &[Paper], ) -> Result<HashMap<PaperId, PaperId>, CoreError>

Save multiple papers, resolving DOI conflicts with existing records. Returns a map of original_id → resolved_id for papers whose ID was remapped to an existing record (callers should use this to fix up search_results and other references).
Source§

fn get(&self, paper_id: &str) -> Result<Option<Paper>, CoreError>

Source§

fn find_by_doi(&self, doi: &str) -> Result<Option<Paper>, CoreError>

Source§

fn find_by_title(&self, title: &str) -> Result<Option<Paper>, CoreError>

Source§

fn list_all(&self, limit: i64, offset: i64) -> Result<Vec<Paper>, CoreError>

Source§

fn update_full_text(&self, paper_id: &str, text: &str) -> Result<(), CoreError>

Persist extracted full text for a paper. Used by read_paper_tool after the first PDF/HTML extraction so subsequent reads (TUI reader, MCP get_annotated_paper) hit the DB instead of re-running pdf-extract. Idempotent — overwrites the existing full_text column.
Source§

fn update_download_state( &self, paper_id: &str, local_path: Option<&str>, status: DownloadStatus, ) -> Result<(), CoreError>

Persist the outcome of a download attempt. local_path is the absolute path to the saved file on success (any non-Failed status); pass None for Failed. last_attempt_at is set to now() automatically. See #112.
Source§

fn update_bibtex_key(&self, paper_id: &str, key: &str) -> Result<(), CoreError>

Assign a stable citation key to a paper. Called once per paper by the 0.6.0 backfill migration (and per-paper on new ingest). Must be unique across the DB — the caller is responsible for running the Better-BibTeX algorithm + disambiguation before calling this. See ADR-006 + scitadel-export::bibtex::assign_keys.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more