pub struct TocEntry {
pub label: String,
pub href: String,
pub children: Vec<TocEntry>,
}Expand description
An entry in the EPUB table of contents.
EPUB navigation uses NCX (Navigation Control for XML) files which define a hierarchical structure of navigation points. Each entry can have child entries, creating a tree structure.
§Example
use epub_parser::TocEntry;
let mut toc_entry = TocEntry::new("Chapter 1".to_string(), "chapter1.xhtml".to_string());
toc_entry.children.push(TocEntry::new(
"Section 1.1".to_string(),
"chapter1.xhtml#section1".to_string()
));
println!("Entry: {} -> {}", toc_entry.label, toc_entry.href);
for child in &toc_entry.children {
println!(" Child: {} -> {}", child.label, child.href);
}Fields§
§label: StringThe display label or title for this navigation point.
This is the text that would be shown in a table of contents.
href: StringThe target URL for this navigation point.
This is a relative path within the EPUB, often with an anchor (e.g., “chapter1.xhtml” or “chapter1.xhtml#section1”).
children: Vec<TocEntry>Child navigation entries.
The NCX format supports hierarchical navigation, so each entry can have nested sub-entries.
Implementations§
Source§impl TocEntry
impl TocEntry
Sourcepub fn new(label: String, href: String) -> Self
pub fn new(label: String, href: String) -> Self
Creates a new TOC entry with the given label and href.
The children vector is initialized as empty.
§Arguments
label- The display text for this entry.href- The target URL/path for this entry.
§Returns
A new TocEntry instance with empty children.
§Example
use epub_parser::TocEntry;
let entry = TocEntry::new("Introduction".to_string(), "intro.xhtml".to_string());
assert_eq!(entry.label, "Introduction");
assert_eq!(entry.href, "intro.xhtml");
assert!(entry.children.is_empty());Trait Implementations§
Auto Trait Implementations§
impl Freeze for TocEntry
impl RefUnwindSafe for TocEntry
impl Send for TocEntry
impl Sync for TocEntry
impl Unpin for TocEntry
impl UnsafeUnpin for TocEntry
impl UnwindSafe for TocEntry
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