Skip to main content

Library

Struct Library 

Source
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: bool§show_hidden: bool

Implementations§

Source§

impl Library

Source

pub fn new<P: AsRef<Path> + Debug>( home: P, database: &Database, name: &str, ) -> Result<Self, Error>

Source

pub fn list<P: AsRef<Path>>( &self, prefix: P, query: Option<&BookQuery>, skip_files: bool, ) -> (Vec<Info>, BTreeSet<PathBuf>)

Source

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.

Source

pub fn page<P: AsRef<Path>>( &self, prefix: P, query: Option<&BookQuery>, page: usize, page_size: usize, ) -> Result<PageResult, Error>

Source

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 directory
  • query - 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 page
  • dir - Direction to search: crate::geom::CycleDir::Next or crate::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).

Source

pub fn resolve_id(&self) -> (i64, &Path)

Source

pub fn add_document(&mut self, info: Info)

Source

pub fn rename<P: AsRef<Path>>( &mut self, path: P, file_name: &str, ) -> Result<(), Error>

Source

pub fn remove<P: AsRef<Path>>(&mut self, path: P) -> Result<(), Error>

Source

pub fn copy_to<P: AsRef<Path>>( &mut self, path: P, other: &mut Library, ) -> Result<(), Error>

Source

pub fn move_to<P: AsRef<Path>>( &mut self, path: P, other: &mut Library, ) -> Result<(), Error>

Source

pub fn clean_up(&mut self)

No-op for the database-backed library: the database maintains its own consistency.

Source

pub fn set_sort(&mut self, sort_method: SortMethod, reverse_order: bool)

Source

pub fn apply<F>(&mut self, f: F)
where F: Fn(&Path, &mut Info),

Source

pub fn sync_reader_info<P: AsRef<Path>>(&mut self, path: P, reader: &ReaderInfo)

Source

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.

Source

pub fn thumbnail_preview<P: AsRef<Path> + Debug>( &self, path: P, ) -> Option<Pixmap>

Source

pub fn set_status<P: AsRef<Path>>(&mut self, path: P, status: SimpleStatus)

Source

pub fn reload(&mut self)

No-op: the database is the source of truth and requires no explicit cache reload.

Source

pub fn flush(&mut self)

No-op: database writes are immediate and do not require an explicit flush.

Source

pub fn is_empty(&self) -> Option<bool>

Source

pub fn next_book_after(&self, fp: Fp) -> Option<Info>

Source

pub fn most_recently_opened_reading_book(&self) -> Option<Info>

Source

fn resolve_fingerprint(&self, path: &Path) -> Option<Fp>

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
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts 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>

Converts 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)

Converts &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)

Converts &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
where T: Any + Send,

§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Sync + Send>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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