Skip to main content

ManifestBuilder

Struct ManifestBuilder 

Source
pub struct ManifestBuilder { /* private fields */ }
Expand description

Manifest builder for EPUB resources

The ManifestBuilder is responsible for managing manifest items in an EPUB publication. The manifest declares all resources (HTML files, images, stylesheets, fonts, etc.) that are part of the EPUB publication.

Each manifest item must have a unique identifier and a path to the resource file. The builder automatically determines the MIME type of each resource based on its content.

§Resource Fallbacks

The manifest supports fallback chains for resources that may not be supported by all reading systems. When adding a resource with a fallback, the builder validates that:

  • The fallback chain does not contain circular references
  • All referenced fallback resources exist in the manifest

The manifest must contain exactly one item with the nav property, which serves as the navigation document (table of contents) of the publication.

Implementations§

Source§

impl ManifestBuilder

Source

pub fn add( &mut self, manifest_source: impl Into<String>, manifest_item: ManifestItem, ) -> Result<&mut Self, EpubError>

Add a manifest item and copy the resource file

Adds a new resource to the manifest and copies the source file to the temporary directory. The builder automatically determines the MIME type based on the file content.

§Parameters
  • manifest_source: Path to the source file on the local filesystem
  • manifest_item: Manifest item with ID and target path
§Return
  • Ok(&mut Self): Successfully added the resource
  • Err(EpubError): Error if the source file doesn’t exist or has an unknown format
Source

pub fn clear(&mut self) -> &mut Self

Clear all manifest items

Removes all manifest items from the builder and deletes the associated files from the temporary directory.

Trait Implementations§

Source§

impl Debug for ManifestBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.