pub struct Chapter { /* private fields */ }Expand description
A chapter of a webnovel
Implementations§
Source§impl Chapter
impl Chapter
Sourcepub fn chapter_url(&self) -> &String
pub fn chapter_url(&self) -> &String
Where can this chapter be found?
Sourcepub fn fiction_url(&self) -> &String
pub fn fiction_url(&self) -> &String
Where can the fiction this chapter is from be found?
Sourcepub fn published_at(&self) -> &Option<DateTime<Utc>>
pub fn published_at(&self) -> &Option<DateTime<Utc>>
date this chapter was published.
Trait Implementations§
Source§impl FromStr for Chapter
Attempts to parse a string into a Chapter.
impl FromStr for Chapter
Attempts to parse a string into a Chapter.
use std::str::FromStr;
use libwebnovel::Chapter;
let chapter_str = r#"
<!--
index: 1
chapter_url: https://read.freewebnovel.me/the-guide-to-conquering-earthlings/chapter-1
fiction_url: https://freewebnovel.com/the-guide-to-conquering-earthlings.html
published_at: not_found
metadata:
authors: Ye Fei Ran, 叶斐然
-->
<h1 class="mainTitle">Chapter 1: 01</h1>
<div class="content">
<p>this is some sample content, whatever man.</p>
</div>
"#;
let chapter = Chapter::from_str(chapter_str).unwrap();
assert_eq!(chapter.title(), &Some("Chapter 1: 01".to_string()));
assert_eq!(chapter.index(), &1);
assert_eq!(
chapter.chapter_url(),
"https://read.freewebnovel.me/the-guide-to-conquering-earthlings/chapter-1"
);
assert_eq!(
chapter.fiction_url(),
"https://freewebnovel.com/the-guide-to-conquering-earthlings.html"
);
assert!(chapter.published_at().is_none());
assert_eq!(
chapter.content(),
"<p>this is some sample content, whatever man.</p>"
);
assert_eq!(
chapter.metadata().get("authors"),
Some(&"Ye Fei Ran, 叶斐然".to_string())
);impl StructuralPartialEq for Chapter
Auto Trait Implementations§
impl Freeze for Chapter
impl RefUnwindSafe for Chapter
impl Send for Chapter
impl Sync for Chapter
impl Unpin for Chapter
impl UnwindSafe for Chapter
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.