use crate::TocElement;
use std::io::Read;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ReferenceType {
Cover,
TitlePage,
Toc,
Index,
Glossary,
Acknowledgements,
Bibliography,
Colophon,
Copyright,
Dedication,
Epigraph,
Foreword,
Loi,
Lot,
Notes,
Preface,
Text,
}
#[derive(Debug)]
pub struct EpubContent<R: Read> {
pub toc: TocElement,
pub content: R,
pub reftype: Option<ReferenceType>,
}
impl<R: Read> EpubContent<R> {
pub fn new<S: Into<String>>(href: S, content: R) -> Self {
EpubContent {
content,
toc: TocElement::new(href, ""),
reftype: None,
}
}
pub fn title<S: Into<String>>(mut self, title: S) -> Self {
self.toc.title = title.into();
self
}
pub fn raw_title<S: Into<String>>(mut self, raw_title: S) -> Self {
self.toc.raw_title = Some(raw_title.into());
self
}
pub fn level(mut self, level: i32) -> Self {
self.toc = self.toc.level(level);
self
}
pub fn child(mut self, elem: TocElement) -> Self {
self.toc = self.toc.child(elem);
self
}
pub fn reftype(mut self, reftype: ReferenceType) -> Self {
self.reftype = Some(reftype);
self
}
}