pub struct Library {
pub home: PathBuf,
pub db: Db,
pub library_id: i64,
pub books: IndexMap<Fp, Info, FxBuildHasher>,
pub paths: FxHashMap<PathBuf, Fp>,
pub fat32_epoch: SystemTime,
pub sort_method: SortMethod,
pub reverse_order: bool,
pub show_hidden: bool,
}Fields§
§home: PathBuf§db: Db§library_id: i64§books: IndexMap<Fp, Info, FxBuildHasher>In-memory cache of book metadata keyed by fingerprint.
SQLite is the source of truth, but the UI and library operations rely on fast iteration, ordering, and path/fingerprint lookups, so we keep a cache of the current library view in memory.
paths: FxHashMap<PathBuf, Fp>Reverse index for quick path-to-fingerprint lookups.
This is derived from the cached entries in books and is rebuilt on reload.
fat32_epoch: SystemTime§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>)
pub fn import(&mut self, settings: &ImportSettings)
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 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 and update the in-memory entry.
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>>(&self, path: P) -> Option<Pixmap>
pub fn set_status<P: AsRef<Path>>(&mut self, path: P, status: SimpleStatus)
pub fn reload(&mut self)
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>
fn fingerprint_for_path(&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 !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
Mutably borrows from an owned value. Read more
§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>
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>
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)
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)
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
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>
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 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>
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