pub enum Backends {
Dumb,
RoyalRoad(RoyalRoad),
LibRead(LibRead),
FreeWebNovel(FreeWebNovel),
LightNovelWorld(LightNovelWorld),
}Expand description
Enum listing all available backends. A new backend may be constructed using
Backends::new.
Variants§
Dumb
A dumb backend that should never be constructed, but is necessary for
iteration (with strum::EnumIter & other features.
RoyalRoad(RoyalRoad)
A RoyalRoad backend
LibRead(LibRead)
A LibRead backend
FreeWebNovel(FreeWebNovel)
A FreeWebNovel backend
LightNovelWorld(LightNovelWorld)
A LightNovelWorld backend
Implementations§
Source§impl Backends
impl Backends
Sourcepub fn get_ordering_function(
&self,
) -> Box<dyn Fn(&Chapter, &Chapter) -> Ordering>
pub fn get_ordering_function( &self, ) -> Box<dyn Fn(&Chapter, &Chapter) -> Ordering>
Returns the ordering function specific to the underlying backend.
§Panics
Panics when self is Backends::Dumb.
Sourcepub fn get_backend_regexps(&self) -> Vec<Regex>
pub fn get_backend_regexps(&self) -> Vec<Regex>
Returns the regexps used by the underlying backend. Backends::Dumb
returns an empty Vec.
Sourcepub fn get_backend_name(&self) -> &'static str
pub fn get_backend_name(&self) -> &'static str
Returns the underlying backend name.
Trait Implementations§
Source§impl Backend for Backends
All possible backend variants are contained within Backends. This
implementation tries to dispatch method calls to their appropriate
implementors.
impl Backend for Backends
All possible backend variants are contained within Backends. This
implementation tries to dispatch method calls to their appropriate
implementors.
use libwebnovel::{Backend, Backends};
let backend =
Backends::new("https://www.royalroad.com/fiction/21220/mother-of-learning").unwrap();
assert_eq!(backend.title().unwrap(), "Mother of Learning");Source§fn get_backend_regexps() -> Vec<Regex>
fn get_backend_regexps() -> Vec<Regex>
Not implemented for Backends. Use
Backends::get_backend_regexps(&self) instead.
Source§fn get_backend_name() -> &'static str
fn get_backend_name() -> &'static str
Not implemented for Backends. Use
Backends::get_backend_name(&self) instead.
Source§fn get_ordering_function() -> Box<dyn Fn(&Chapter, &Chapter) -> Ordering>
fn get_ordering_function() -> Box<dyn Fn(&Chapter, &Chapter) -> Ordering>
Can’t implement this function for backends without reference to self.
use Backends::get_ordering_function(&self) instead.
Source§fn new(url: &str) -> Result<Self, BackendError>
fn new(url: &str) -> Result<Self, BackendError>
Builds a new backend for a given URL. Auto-detects the backend to use
from the given URL, returning BackendError::NoMatchingBackendFound
if none could be found.
use libwebnovel::{Backend, Backends};
let backend =
Backends::new("https://www.royalroad.com/fiction/21220/mother-of-learning").unwrap();
assert_eq!(backend.title().unwrap(), "Mother of Learning");Source§fn title(&self) -> Result<String, BackendError>
fn title(&self) -> Result<String, BackendError>
Returns the title of the webnovel. See Backends::new for an example.
Source§fn url(&self) -> String
fn url(&self) -> String
Returns the URL of the webnovel.
use libwebnovel::{Backend, Backends};
let backend =
Backends::new("https://www.royalroad.com/fiction/21220/mother-of-learning").unwrap();
assert_eq!(
backend.url(),
"https://www.royalroad.com/fiction/21220/mother-of-learning"
);Returns the author(s) of the webnovel
use libwebnovel::{Backend, Backends};
let backend =
Backends::new("https://www.royalroad.com/fiction/21220/mother-of-learning").unwrap();
assert_eq!(
backend.get_authors().unwrap(),
vec!["nobody103".to_string()]
);Source§fn get_chapter(&self, chapter_number: usize) -> Result<Chapter, BackendError>
fn get_chapter(&self, chapter_number: usize) -> Result<Chapter, BackendError>
Returns a chapter of the webnovel, given its chapter number
use libwebnovel::{Backend, Backends};
let backend =
Backends::new("https://www.royalroad.com/fiction/21220/mother-of-learning").unwrap();
let chapter = backend.get_chapter(1).unwrap();
assert_eq!(
chapter.title(),
&Some("1. Good Morning Brother".to_string())
);
assert_eq!(*chapter.index(), 1);Source§fn get_chapter_count(&self) -> Result<usize, BackendError>
fn get_chapter_count(&self) -> Result<usize, BackendError>
Returns the total count of the webnovel’s chapters.
§Example
use libwebnovel::{Backend, Backends};
let backend =
Backends::new("https://www.royalroad.com/fiction/21220/mother-of-learning").unwrap();
assert_eq!(backend.get_chapter_count().unwrap(), 109);§Panics
Panics when used on the Backends::Dumb backend.
Source§fn immutable_identifier(&self) -> Result<String, BackendError>
fn immutable_identifier(&self) -> Result<String, BackendError>
Source§fn get_chapter_list(&self) -> Result<Vec<(usize, String)>, BackendError>
fn get_chapter_list(&self) -> Result<Vec<(usize, String)>, BackendError>
Source§fn get_chapters(&self) -> Result<Vec<Chapter>, BackendError>
fn get_chapters(&self) -> Result<Vec<Chapter>, BackendError>
Self::get_chapter repeatedly