pub enum FragmentationContext {
Continuous {
width: f32,
container: Fragmentainer,
},
Paged {
page_size: LogicalSize,
pages: Vec<Fragmentainer>,
},
MultiColumn {
column_width: f32,
column_height: f32,
gap: f32,
columns: Vec<Fragmentainer>,
},
Regions {
regions: Vec<Fragmentainer>,
},
}Expand description
Represents a series of containers that content flows into during layout.
This is the core abstraction for fragmentation support. Different media types use different fragmentation contexts:
- Screen rendering: Continuous (single infinite container)
- Print rendering: Paged (series of fixed-size page containers)
- Multi-column layout: MultiColumn (series of column containers)
Variants§
Continuous
Continuous media (screen): single infinite container.
Used for normal screen rendering where content can scroll indefinitely. The container grows as needed and never forces breaks.
Fields
container: FragmentainerThe single fragmentainer (grows infinitely)
Paged
Paged media (print): series of page boxes.
Used for PDF generation and print preview. Content flows from one page to the next when a page is full.
Fields
page_size: LogicalSizeSize of each page
pages: Vec<Fragmentainer>All pages (fragmentainers) that have been created
MultiColumn
Multi-column layout: series of column boxes.
Future support for CSS multi-column layout.
Fields
columns: Vec<Fragmentainer>All columns that have been created
Regions
CSS Regions: series of region boxes.
Future support for CSS Regions specification.
Fields
regions: Vec<Fragmentainer>Pre-defined region boxes
Implementations§
Source§impl FragmentationContext
impl FragmentationContext
Sourcepub fn new_continuous(width: f32) -> Self
pub fn new_continuous(width: f32) -> Self
Create a continuous fragmentation context for screen rendering.
width- The viewport width
Sourcepub fn new_paged(page_size: LogicalSize) -> Self
pub fn new_paged(page_size: LogicalSize) -> Self
Create a paged fragmentation context for print rendering.
page_size- The size of each page
Sourcepub fn fragmentainer_count(&self) -> usize
pub fn fragmentainer_count(&self) -> usize
Get the number of fragmentainers (pages, columns, etc.) in this context.
Sourcepub fn current(&self) -> &Fragmentainer
pub fn current(&self) -> &Fragmentainer
Get a reference to the current fragmentainer being filled.
Sourcepub fn current_mut(&mut self) -> &mut Fragmentainer
pub fn current_mut(&mut self) -> &mut Fragmentainer
Get a mutable reference to the current fragmentainer being filled.
Sourcepub fn advance(&mut self) -> Result<(), String>
pub fn advance(&mut self) -> Result<(), String>
Advance to the next fragmentainer, creating a new one if necessary.
- For continuous media, this is a no-op (continuous media can’t advance).
- For paged media, this creates a new page.
- For regions, this fails if no more regions are available.
§Returns
Ok(())if the advance succeeded,Err(String)if it failed (e.g., no more regions).
Sourcepub fn fragmentainers(&self) -> Vec<&Fragmentainer>
pub fn fragmentainers(&self) -> Vec<&Fragmentainer>
Get all fragmentainers in this context.
Sourcepub fn page_size(&self) -> Option<LogicalSize>
pub fn page_size(&self) -> Option<LogicalSize>
Get the page size for paged media, or None for other contexts.
Sourcepub fn page_content_height(&self) -> f32
pub fn page_content_height(&self) -> f32
Get the page content height (page height minus margins). For continuous media, returns f32::MAX.
Trait Implementations§
Source§impl Clone for FragmentationContext
impl Clone for FragmentationContext
Source§fn clone(&self) -> FragmentationContext
fn clone(&self) -> FragmentationContext
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for FragmentationContext
impl RefUnwindSafe for FragmentationContext
impl Send for FragmentationContext
impl Sync for FragmentationContext
impl Unpin for FragmentationContext
impl UnwindSafe for FragmentationContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more