SpineItem

Struct SpineItem 

Source
pub struct SpineItem {
    pub idref: String,
    pub id: Option<String>,
    pub properties: Option<String>,
    pub linear: bool,
}
Expand description

Represents an item in the EPUB spine, defining the reading order of the publication

The SpineItem structure represents a single item in the EPUB spine, which defines the linear reading order of the publication’s content documents. Each spine item references a resource declared in the manifest and indicates whether it should be included in the linear reading sequence.

The spine is a crucial component of an EPUB publication as it determines the recommended reading order of content documents. Items can be marked as linear (part of the main reading flow) or non-linear (supplementary content that may be accessed out of sequence).

§Builder Methods

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

use lib_epub::types::SpineItem;

let spine_item = SpineItem::new("content-1")
    .with_id("spine-1")
    .append_property("page-spread-right")
    .set_linear(false)
    .build();

Fields§

§idref: String

The ID reference to a manifest item

This field contains the ID of the manifest item that this spine item references. It establishes the connection between the reading order (spine) and the actual content resources (manifest). The referenced ID must exist in the manifest.

§id: Option<String>

Optional identifier for this spine item

§properties: Option<String>

Optional properties associated with this spine item

This field contains a space-separated list of properties that apply to this spine item. These properties can indicate special handling requirements, layout preferences, or other characteristics.

§linear: bool

Indicates whether this item is part of the linear reading order

When true, this spine item is part of the main linear reading sequence. When false, this item represents supplementary content that may be accessed out of the normal reading order (e.g., through hyperlinks).

Non-linear items are typically used for content like footnotes, endnotes, appendices, or other supplementary materials that readers might access on-demand rather than sequentially.

Implementations§

Source§

impl SpineItem

Source

pub fn new(idref: &str) -> Self

Creates a new spine item referencing a manifest item

Requires the builder feature.

By default, spine items are linear.

§Parameters
  • idref - The ID of the manifest item this spine item references
Source

pub fn with_id(&mut self, id: &str) -> &mut Self

Sets the ID of the spine item

Requires the builder feature.

§Parameters
  • id - The ID to assign to this spine item
Source

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

Appends a property to the spine item

Requires the builder feature.

§Parameters
  • property - The property to add
Source

pub fn set_linear(&mut self, linear: bool) -> &mut Self

Sets whether this spine item is part of the linear reading order

Requires the builder feature.

§Parameters
  • linear - true if the item is part of the linear reading order, false otherwise
Source

pub fn build(&self) -> Self

Builds the final spine item

Requires the builder feature.

Trait Implementations§

Source§

impl Clone for SpineItem

Source§

fn clone(&self) -> SpineItem

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 SpineItem

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.