pub struct EpubContent<R: Read> {
    pub toc: TocElement,
    pub content: R,
    pub reftype: Option<ReferenceType>,
}
Expand description

Represents a XHTML file that can be added to an EPUB document.

This struct is designed to be used with the add_content method of the `EpubBuilder.

Example

use epub_builder::{EpubContent, TocElement};

let page_content = "Some XHTML content";

// Creates a new EpubContent
let content = EpubContent::new("intro.xhtml", page_content.as_bytes())
// ... and sets a title so it is added to the TOC
    .title("Introduction")
// ... and add some toc information on the document structure
    .child(TocElement::new("intro.xhtml#1", "Section 1"))
    .child(TocElement::new("intro.xhtml#2", "Section 2"));

Fields

toc: TocElement

The title and url, plus sublevels

content: R

The content

reftype: Option<ReferenceType>

Properties. See EpubProperties

Implementations

Creates a new EpubContent

By default, this element is at level 1, and it has no title (meaning it won’t be added to the Table of Contents.

Set the title of this content. If no title is set, this part of the book will not be displayed in the table of content.

Set the level

Adds a sublevel to the toc

Sets reference type of this content

If this is set, this will list this item as a reference in the guide section.

See www.idpf.org/epub/20/spec/OPF_2.0.1_draft.htm#Section2.3

Example

Reference an item as the title page:

use epub_builder::{EpubContent, ReferenceType};
let dummy = "Should be a XHTML file";
let item = EpubContent::new("title.xhtml", dummy.as_bytes())
     .title("Title")
     .reftype(ReferenceType::TitlePage);

Trait Implementations

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