pub struct MetadataItem {
pub id: Option<String>,
pub property: String,
pub value: String,
pub lang: Option<String>,
pub refined: Vec<MetadataRefinement>,
}Expand description
Represents a metadata item in the EPUB publication
The MetadataItem structure represents a single piece of metadata from the EPUB publication.
Metadata items contain information about the publication such as title, author, identifier,
language, and other descriptive information.
In EPUB 3.0, metadata items can have refinements that provide additional details about the main metadata item. For example, a title metadata item might have refinements that specify it is the main title of the publication.
§Builder Methods
When the builder feature is enabled, this struct provides convenient builder methods:
use lib_epub::types::MetadataItem;
let metadata = MetadataItem::new("title", "Sample Book")
.with_id("title-1")
.with_lang("en")
.build();Fields§
§id: Option<String>Optional unique identifier for this metadata item
Used to reference this metadata item from other elements or refinements. In EPUB 3.0, this ID is particularly important for linking with metadata refinements.
property: StringThe metadata property name
This field specifies the type of metadata this item represents. Common properties include “title”, “creator”, “identifier”, “language”, “publisher”, etc. These typically correspond to Dublin Core metadata terms.
value: StringThe metadata value
lang: Option<String>Optional language code for this metadata item
refined: Vec<MetadataRefinement>Refinements of this metadata item
In EPUB 3.x, metadata items can have associated refinements that provide additional information about the main metadata item. For example, a creator metadata item might have refinements specifying the creator’s role (author, illustrator, etc.) or file-as.
In EPUB 2.x, metadata items may contain custom attributes, which will also be parsed as refinement.
Implementations§
Source§impl MetadataItem
impl MetadataItem
Sourcepub fn new(property: &str, value: &str) -> Self
pub fn new(property: &str, value: &str) -> Self
Creates a new metadata item with the given property and value
Requires the builder feature.
§Parameters
property- The metadata property name (e.g., “title”, “creator”)value- The metadata value
Sourcepub fn with_id(&mut self, id: &str) -> &mut Self
pub fn with_id(&mut self, id: &str) -> &mut Self
Sets the ID of the metadata item
Requires the builder feature.
§Parameters
id- The ID to assign to this metadata item
Sourcepub fn with_lang(&mut self, lang: &str) -> &mut Self
pub fn with_lang(&mut self, lang: &str) -> &mut Self
Sets the language of the metadata item
Requires the builder feature.
§Parameters
lang- The language code (e.g., “en”, “fr”, “zh-CN”)
Sourcepub fn append_refinement(&mut self, refine: MetadataRefinement) -> &mut Self
pub fn append_refinement(&mut self, refine: MetadataRefinement) -> &mut Self
Trait Implementations§
Source§impl Clone for MetadataItem
impl Clone for MetadataItem
Source§fn clone(&self) -> MetadataItem
fn clone(&self) -> MetadataItem
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more