Struct libwebnovel_storage::Novel
source · pub struct Novel { /* private fields */ }Expand description
Represents a novel. Stored on disk at the following path: <base_library_path>/<novel.title()>/
TODO: Detect remote novel title changes
Implementations§
source§impl Novel
impl Novel
sourcepub fn new(
url: impl Into<Url>,
library_path: &Path,
) -> Result<Self, LibraryError>
pub fn new( url: impl Into<Url>, library_path: &Path, ) -> Result<Self, LibraryError>
Returns a new Novel from the given URL. Functionally equivalent to
[Novel::try_from(Url)].
sourcepub fn title(&self) -> Result<String, LibraryError>
pub fn title(&self) -> Result<String, LibraryError>
Returns the title of the novel
sourcepub fn get_chapter_storage_path(novel_path: &Path) -> PathBuf
pub fn get_chapter_storage_path(novel_path: &Path) -> PathBuf
returns where all the chapters are stored. static alternative to
[self.chapter_storage_path()].
sourcepub fn get_cover_storage_path(novel_path: &Path) -> PathBuf
pub fn get_cover_storage_path(novel_path: &Path) -> PathBuf
returns where the cover image is stored. static alternative to
[self.cover_storage_path].
sourcepub fn chapter_storage_path(&self) -> PathBuf
pub fn chapter_storage_path(&self) -> PathBuf
Returns where all the chapters are stored. Alternative to the static
Self::get_chapter_storage_path.
sourcepub fn cover_storage_path(&self) -> PathBuf
pub fn cover_storage_path(&self) -> PathBuf
Returns where the cover image is stored. Alternative to the static
Self::get_cover_storage_path.
sourcepub fn download_cover(&self) -> Result<(), LibraryError>
pub fn download_cover(&self) -> Result<(), LibraryError>
Downloads the cover file and places it in [self.cover_image_path],
performing appropriate image format conversions if necessary.
sourcepub fn update(&mut self) -> Result<(), LibraryError>
pub fn update(&mut self) -> Result<(), LibraryError>
Fetch remote chapters & saves them locally. Will attempt to fix duplicates, ordering, and detect collisions.
sourcepub fn consolidate_chapter_collection(&mut self)
pub fn consolidate_chapter_collection(&mut self)
Sorts, dedups and tries to fix chapter indexes in the current “live” chapter list.
sourcepub fn update_iter(&mut self) -> NovelChapterUpdateIter<'_> ⓘ
pub fn update_iter(&mut self) -> NovelChapterUpdateIter<'_> ⓘ
Returns an iterator that will fetch the chapters, returning a Result for
each operation. See NovelChapterUpdateIter::next for more info.
Will not attempt to handle duplicates & other stuff.
§Panics
Panics when:
- [
self.get_missing_chapters_indexes] panics
sourcepub fn get_missing_chapters_indexes(&self) -> Result<Vec<usize>, LibraryError>
pub fn get_missing_chapters_indexes(&self) -> Result<Vec<usize>, LibraryError>
Returns chapter indexes that are present in the source but not locally.
sourcepub fn get_local_chapter_count(&self) -> Result<usize, LibraryError>
pub fn get_local_chapter_count(&self) -> Result<usize, LibraryError>
Returns the count of locally-saved chapters
sourcepub fn get_remote_chapter_count(&self) -> Result<usize, LibraryError>
pub fn get_remote_chapter_count(&self) -> Result<usize, LibraryError>
returns the total count of remote chapters
sourcepub fn load_local_chapters(&mut self) -> Result<(), LibraryError>
pub fn load_local_chapters(&mut self) -> Result<(), LibraryError>
Loads local chapters and saves them in self.chapters. Overrides any
currently loaded chapters.
sourcepub fn get_local_chapters(&self) -> Result<Vec<Chapter>, LibraryError>
pub fn get_local_chapters(&self) -> Result<Vec<Chapter>, LibraryError>
Returns a vector of all local Chapter.
sourcepub fn novel_path(&self) -> &Path
pub fn novel_path(&self) -> &Path
Returns the root path of where this novel stores its files.
Trait Implementations§
source§impl<'de> Deserialize<'de> for Novel
impl<'de> Deserialize<'de> for Novel
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for Novel
impl !RefUnwindSafe for Novel
impl !Send for Novel
impl !Sync for Novel
impl Unpin for Novel
impl UnwindSafe for Novel
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§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