pub struct RenderBookPageMap { /* private fields */ }Expand description
Compact chapter-level rendered page index for locator and remap operations.
Implementations§
Source§impl RenderBookPageMap
impl RenderBookPageMap
Sourcepub fn from_chapter_page_counts(
chapters: &[ChapterRef],
chapter_page_counts: &[usize],
) -> Self
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.
Sourcepub fn entries(&self) -> &[RenderBookPageMapEntry]
pub fn entries(&self) -> &[RenderBookPageMapEntry]
Chapter-level entries in spine order.
Sourcepub fn total_pages(&self) -> usize
pub fn total_pages(&self) -> usize
Total rendered page count represented by this map.
Sourcepub fn chapter_start_page_index(&self, chapter_index: usize) -> Option<usize>
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.
Sourcepub fn chapter_page_range(&self, chapter_index: usize) -> Option<PageRange>
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.
Sourcepub fn resolve_href(&self, href: &str) -> Option<RenderLocatorPageTarget>
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.
Sourcepub fn resolve_href_with_fragment_progress(
&self,
href: &str,
fragment_progress: Option<f32>,
) -> Option<RenderLocatorPageTarget>
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.
Sourcepub fn resolve_toc_href(&self, href: &str) -> Option<RenderLocatorPageTarget>
pub fn resolve_toc_href(&self, href: &str) -> Option<RenderLocatorPageTarget>
Alias for resolving TOC href targets.
Sourcepub fn resolve_locator(
&self,
locator: &Locator,
navigation: Option<&Navigation>,
) -> Option<RenderLocatorPageTarget>
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.
Sourcepub fn reading_position_token_for_page_index(
&self,
global_page_index: usize,
) -> Option<RenderReadingPositionToken>
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.
Sourcepub fn remap_reading_position_token(
&self,
token: &RenderReadingPositionToken,
) -> Option<usize>
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
impl Clone for RenderBookPageMap
Source§fn clone(&self) -> RenderBookPageMap
fn clone(&self) -> RenderBookPageMap
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more