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: StringThe unique identifier for this resource item
path: PathBufThe 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: StringThe 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
impl ManifestItem
Sourcepub fn append_property(&mut self, property: &str) -> &mut Self
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
Sourcepub fn with_fallback(&mut self, fallback: &str) -> &mut Self
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
Sourcepub fn attributes(&self) -> Vec<(&str, &str)>
pub fn attributes(&self) -> Vec<(&str, &str)>
Gets the XML attributes for this manifest item
Trait Implementations§
Source§impl Clone for ManifestItem
impl Clone for ManifestItem
Source§fn clone(&self) -> ManifestItem
fn clone(&self) -> ManifestItem
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more