pub struct Chapter {
pub name: String,
pub content: String,
pub number: Option<SectionNumber>,
pub sub_items: Vec<BookItem>,
pub path: Option<PathBuf>,
pub source_path: Option<PathBuf>,
pub parent_names: Vec<String>,
}
Expand description
The representation of a “chapter”, usually mapping to a single file on disk however it may contain multiple sub-chapters.
Fields§
§name: String
The chapter’s name.
content: String
The chapter’s contents.
number: Option<SectionNumber>
The chapter’s section number, if it has one.
sub_items: Vec<BookItem>
Nested items.
path: Option<PathBuf>
The chapter’s location, relative to the SUMMARY.md
file.
source_path: Option<PathBuf>
The chapter’s source file, relative to the SUMMARY.md
file.
parent_names: Vec<String>
An ordered list of the names of each chapter above this one in the hierarchy.
Implementations§
source§impl Chapter
impl Chapter
sourcepub fn new<P: Into<PathBuf>>(
name: &str,
content: String,
p: P,
parent_names: Vec<String>
) -> Chapter
pub fn new<P: Into<PathBuf>>( name: &str, content: String, p: P, parent_names: Vec<String> ) -> Chapter
Create a new chapter with the provided content.
sourcepub fn new_draft(name: &str, parent_names: Vec<String>) -> Self
pub fn new_draft(name: &str, parent_names: Vec<String>) -> Self
Create a new draft chapter that is not attached to a source markdown file (and thus has no content).
sourcepub fn is_draft_chapter(&self) -> bool
pub fn is_draft_chapter(&self) -> bool
Check if the chapter is a draft chapter, meaning it has no path to a source markdown file.
Trait Implementations§
source§impl<'de> Deserialize<'de> for Chapter
impl<'de> Deserialize<'de> for Chapter
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>,
Deserialize this value from the given Serde deserializer. Read more
source§impl PartialEq for Chapter
impl PartialEq for Chapter
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