pub struct Library {
pub home: PathBuf,
pub db: Db,
pub library_id: i64,
pub sort_method: SortMethod,
pub reverse_order: bool,
pub show_hidden: bool,
}Fields§
§home: PathBuf§db: Db§library_id: i64§sort_method: SortMethod§reverse_order: boolImplementations§
Source§impl Library
impl Library
pub fn new<P: AsRef<Path> + Debug>( home: P, database: &Database, name: &str, ) -> Result<Self, Error>
pub fn list<P: AsRef<Path>>( &self, prefix: P, query: Option<&BookQuery>, skip_files: bool, ) -> (Vec<Info>, BTreeSet<PathBuf>)
Sourcepub fn list_by<P: AsRef<Path>>(
&self,
prefix: P,
query: Option<&BookQuery>,
sort_method: SortMethod,
reverse_order: bool,
skip_files: bool,
) -> (Vec<Info>, BTreeSet<PathBuf>)
pub fn list_by<P: AsRef<Path>>( &self, prefix: P, query: Option<&BookQuery>, sort_method: SortMethod, reverse_order: bool, skip_files: bool, ) -> (Vec<Info>, BTreeSet<PathBuf>)
Lists books and direct subdirectories under prefix using explicit sort parameters.
When no query is active, sorting is delegated to SQLite. When a query is active it cannot be expressed in SQL, so books are loaded in full and sorted in Rust.
pub fn page<P: AsRef<Path>>( &self, prefix: P, query: Option<&BookQuery>, page: usize, page_size: usize, ) -> Result<PageResult, Error>
Sourcepub fn neighbor_status_change_page<P: AsRef<Path>>(
&self,
prefix: P,
query: Option<&BookQuery>,
current_page: usize,
page_size: usize,
dir: CycleDir,
) -> Result<Option<usize>, Error>
pub fn neighbor_status_change_page<P: AsRef<Path>>( &self, prefix: P, query: Option<&BookQuery>, current_page: usize, page_size: usize, dir: CycleDir, ) -> Result<Option<usize>, Error>
Finds the next or previous results page where the visible status changes.
When browsing through a paginated list of books, this function helps locate
the boundary page where the SimpleStatus (New, Reading, or Finished)
changes from one value to another.
§Arguments
prefix- Path prefix to filter books within a specific directoryquery- Optional filter query to apply (e.g., by title, author)current_page- The page number we’re currently viewing (0-indexed)page_size- Number of books per pagedir- Direction to search:crate::geom::CycleDir::Nextorcrate::geom::CycleDir::Previous
§Returns
Ok(Some(page_number)) where the status changes, or Ok(None) if no
status change is found in that direction.
§Example
Suppose books are sorted and paginated with 20 books per page:
- Page 0: books 0-19 (status: New)
- Page 1: books 20-39 (status: New)
- Page 2: books 40-59 (status: Reading)
- Page 3: books 60-79 (status: Finished)
If currently on page 1 looking for the next status change with
CycleDir::Next, the function examines the last book on page 1 (book 19,
status New), then scans forward until it finds book 40 with status
Reading. It returns Ok(Some(2)) - the page where the status first
differs.
Similarly, with CycleDir::Previous from page 3, it examines book 60
(status Finished) and scans backward to find the boundary, returning
Ok(Some(2)).
Returns Ok(None) if there is no status change in the requested direction
(e.g., searching forward from the last page of uniform status).
pub fn resolve_id(&self) -> (i64, &Path)
pub fn add_document(&mut self, info: Info)
pub fn rename<P: AsRef<Path>>( &mut self, path: P, file_name: &str, ) -> Result<(), Error>
pub fn remove<P: AsRef<Path>>(&mut self, path: P) -> Result<(), Error>
pub fn copy_to<P: AsRef<Path>>( &mut self, path: P, other: &mut Library, ) -> Result<(), Error>
pub fn move_to<P: AsRef<Path>>( &mut self, path: P, other: &mut Library, ) -> Result<(), Error>
Sourcepub fn clean_up(&mut self)
pub fn clean_up(&mut self)
No-op for the database-backed library: the database maintains its own consistency.
pub fn set_sort(&mut self, sort_method: SortMethod, reverse_order: bool)
pub fn apply<F>(&mut self, f: F)
pub fn sync_reader_info<P: AsRef<Path>>(&mut self, path: P, reader: &ReaderInfo)
Sourcepub fn sync_toc<P: AsRef<Path>>(&mut self, path: P, toc: Vec<SimpleTocEntry>)
pub fn sync_toc<P: AsRef<Path>>(&mut self, path: P, toc: Vec<SimpleTocEntry>)
Persist a book’s TOC to the database.
Call this when a TOC has been parsed from a document for the first time so subsequent opens can serve it from the database without re-parsing.
pub fn thumbnail_preview<P: AsRef<Path> + Debug>( &self, path: P, ) -> Option<Pixmap>
pub fn set_status<P: AsRef<Path>>(&mut self, path: P, status: SimpleStatus)
Sourcepub fn reload(&mut self)
pub fn reload(&mut self)
No-op: the database is the source of truth and requires no explicit cache reload.
Sourcepub fn flush(&mut self)
pub fn flush(&mut self)
No-op: database writes are immediate and do not require an explicit flush.
pub fn is_empty(&self) -> Option<bool>
pub fn next_book_after(&self, fp: Fp) -> Option<Info>
pub fn most_recently_opened_reading_book(&self) -> Option<Info>
fn resolve_fingerprint(&self, path: &Path) -> Option<Fp>
Auto Trait Implementations§
impl Freeze for Library
impl !RefUnwindSafe for Library
impl Send for Library
impl Sync for Library
impl Unpin for Library
impl UnsafeUnpin for Library
impl !UnwindSafe for Library
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more