pub struct TocElement {
    pub level: i32,
    pub url: String,
    pub title: 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: i32

The level. 0: part, 1: chapter, 2: section, …

url: String

The link

title: String

Title of this entry

children: Vec<TocElement>

Inner elements

Implementations

Creates a new element of the toc

By default, the element’s level is 1 and it has no children.

Sets the level of a TocElement

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`.

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.