ManifestItem

Struct ManifestItem 

Source
pub struct ManifestItem {
    pub id: String,
    pub path: PathBuf,
    pub mime: String,
    pub properties: Option<String>,
    pub fallback: Option<String>,
}
Expand description

Represents a resource item declared in the EPUB manifest

The ManifestItem structure represents a single resource file declared in the EPUB publication’s manifest. Each manifest item describes a resource that is part of the publication, including its location, media type, and optional properties or fallback relationships.

The manifest serves as a comprehensive inventory of all resources in an EPUB publication. Every resource that is part of the publication must be declared in the manifest, and resources not listed in the manifest should not be accessed by reading systems.

Manifest items support the fallback mechanism, allowing alternative versions of a resource to be specified. This is particularly important for foreign resources (resources with non-core media types) that may not be supported by all reading systems.

§Builder Methods

When the builder feature is enabled, this struct provides convenient builder methods:

use lib_epub::types::ManifestItem;

let manifest_item = ManifestItem::new("cover", "images/cover.jpg")
    .unwrap()
    .append_property("cover-image")
    .with_fallback("cover-fallback")
    .build();

Fields§

§id: String

The unique identifier for this resource item

§path: PathBuf

The path to the resource file within the EPUB container

This field contains the normalized path to the resource file relative to the root of the EPUB container. The path is processed during parsing to handle various EPUB path conventions (absolute paths, relative paths, etc.).

§mime: String

The media type of the resource

§properties: Option<String>

Optional properties associated with this resource

This field contains a space-separated list of properties that apply to this resource. Properties provide additional information about how the resource should be treated.

§fallback: Option<String>

Optional fallback resource identifier

This field specifies the ID of another manifest item that serves as a fallback for this resource. Fallbacks are used when a reading system does not support the media type of the primary resource. The fallback chain allows publications to include foreign resources while maintaining compatibility with older or simpler reading systems.

The value is the ID of another manifest item, which must exist in the manifest. If None, this resource has no fallback.

Implementations§

Source§

impl ManifestItem

Source

pub fn new(id: &str, path: &str) -> Result<Self, EpubError>

Creates a new manifest item

Requires the builder feature.

§Parameters
  • id - The unique identifier for this resource
  • path - The path to the resource file
§Errors

Returns an error if the path starts with “../” which is not allowed.

Source

pub fn append_property(&mut self, property: &str) -> &mut Self

Appends a property to the manifest item

Requires the builder feature.

§Parameters
  • property - The property to add
Source

pub fn with_fallback(&mut self, fallback: &str) -> &mut Self

Sets the fallback for this manifest item

Requires the builder feature.

§Parameters
  • fallback - The ID of the fallback manifest item
Source

pub fn build(&self) -> Self

Builds the final manifest item

Requires the builder feature.

Source

pub fn attributes(&self) -> Vec<(&str, &str)>

Gets the XML attributes for this manifest item

Trait Implementations§

Source§

impl Clone for ManifestItem

Source§

fn clone(&self) -> ManifestItem

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ManifestItem

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.