Skip to main content

RenderBookPageMap

Struct RenderBookPageMap 

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

Compact chapter-level rendered page index for locator and remap operations.

Implementations§

Source§

impl RenderBookPageMap

Source

pub fn from_chapter_page_counts( chapters: &[ChapterRef], chapter_page_counts: &[usize], ) -> Self

Build a compact page map from spine chapters and rendered page counts.

chapter_page_counts is interpreted in spine-index space. Missing entries are treated as 0 pages.

Source

pub fn entries(&self) -> &[RenderBookPageMapEntry]

Chapter-level entries in spine order.

Source

pub fn total_pages(&self) -> usize

Total rendered page count represented by this map.

Source

pub fn chapter_start_page_index(&self, chapter_index: usize) -> Option<usize>

Resolve the first rendered page for chapter_index.

Returns None if the chapter has zero rendered pages or is absent.

Source

pub fn chapter_page_range(&self, chapter_index: usize) -> Option<PageRange>

Resolve the rendered global page range for chapter_index.

Returns None if the chapter has zero rendered pages or is absent.

Source

pub fn resolve_href(&self, href: &str) -> Option<RenderLocatorPageTarget>

Resolve a chapter/fragment href into a rendered page target.

Fragment mapping is best-effort. Until anchor-level mappings are available, fragment hrefs deterministically fall back to chapter start.

Source

pub fn resolve_href_with_fragment_progress( &self, href: &str, fragment_progress: Option<f32>, ) -> Option<RenderLocatorPageTarget>

Resolve a chapter/fragment href with optional normalized fragment progress.

When fragment_progress is provided for hrefs containing a fragment, the target page is resolved to the nearest page in that chapter and the target kind is marked as FragmentAnchor.

Source

pub fn resolve_toc_href(&self, href: &str) -> Option<RenderLocatorPageTarget>

Alias for resolving TOC href targets.

Source

pub fn resolve_locator( &self, locator: &Locator, navigation: Option<&Navigation>, ) -> Option<RenderLocatorPageTarget>

Resolve a epub_stream::Locator into a rendered page target.

Pass navigation when resolving Locator::TocId.

Source

pub fn reading_position_token_for_page_index( &self, global_page_index: usize, ) -> Option<RenderReadingPositionToken>

Build a persisted reading-position token from a rendered global page index.

Out-of-range indices are clamped to the nearest valid page.

Source

pub fn remap_reading_position_token( &self, token: &RenderReadingPositionToken, ) -> Option<usize>

Remap a persisted reading-position token into this page map.

Remap keeps chapter identity when the chapter is still present and has rendered pages; otherwise it falls back to global progress remap.

Trait Implementations§

Source§

impl Clone for RenderBookPageMap

Source§

fn clone(&self) -> RenderBookPageMap

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 RenderBookPageMap

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for RenderBookPageMap

Source§

fn default() -> RenderBookPageMap

Returns the “default value” for a type. Read more
Source§

impl PartialEq for RenderBookPageMap

Source§

fn eq(&self, other: &RenderBookPageMap) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for RenderBookPageMap

Source§

impl StructuralPartialEq for RenderBookPageMap

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> 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.