pub struct TocElement {
pub level: i32,
pub url: String,
pub title: String,
pub raw_title: Option<String>,
pub children: Vec<TocElement>,
}Expand description
An element of the Table of contents
§Example
use epub_builder::TocElement;
TocElement::new("chapter_1.xhtml", "Chapter 1")
.child(TocElement::new("chapter_1.xhtml#1", "Chapter 1, section 1")
.child(TocElement::new("chapter_1.xhtml#1-1", "Chapter 1, section 1, subsection 1")));Fields§
§level: i32The level. 0: part, 1: chapter, 2: section, …
url: StringThe link
title: StringTitle of this entry
raw_title: Option<String>Title of this entry without HTML tags (if None, defaults to the main one)
children: Vec<TocElement>Inner elements
Implementations§
source§impl TocElement
impl TocElement
sourcepub fn new<S1: Into<String>, S2: Into<String>>(url: S1, title: S2) -> TocElement
pub fn new<S1: Into<String>, S2: Into<String>>(url: S1, title: S2) -> TocElement
Creates a new element of the toc
By default, the element’s level is 1 and it has no children.
sourcepub fn raw_title<S: Into<String>>(self, title: S) -> TocElement
pub fn raw_title<S: Into<String>>(self, title: S) -> TocElement
Adds an alternate version of the title without HTML tags.
Useful only if you disable escaping of HTML fields.
sourcepub fn child(self, child: TocElement) -> Self
pub fn child(self, child: TocElement) -> Self
Add a child to this element.
This adjust the level of the child to be the level of its parents, plus 1; this means that there is no point in manually setting the level to elements added with this method.
§Example
use epub_builder::TocElement;
let elem = TocElement::new("foo.xhtml", "Foo")
.child(TocElement::new("bar.xhtml", "Bar")
.level(42));
// `Bar`'s level wiss still be `2`.sourcepub fn add(&mut self, element: TocElement)
pub fn add(&mut self, element: TocElement)
Add element to self or to children, according to its level
This will adds element directly to self if its level is equal or less
to the last children element; else it will insert it to the last child.
See the add method of `Toc.
Trait Implementations§
source§impl Clone for TocElement
impl Clone for TocElement
source§fn clone(&self) -> TocElement
fn clone(&self) -> TocElement
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for TocElement
impl RefUnwindSafe for TocElement
impl Send for TocElement
impl Sync for TocElement
impl Unpin for TocElement
impl UnwindSafe for TocElement
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)