Skip to main content

FragmentationContext

Enum FragmentationContext 

Source
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

§width: f32

Width of the viewport

§container: Fragmentainer

The 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: LogicalSize

Size 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

§column_width: f32

Width of each column

§column_height: f32

Height of each column

§gap: f32

Gap between columns

§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

Source

pub fn new_continuous(width: f32) -> Self

Create a continuous fragmentation context for screen rendering.

  • width - The viewport width
Source

pub fn new_paged(page_size: LogicalSize) -> Self

Create a paged fragmentation context for print rendering.

  • page_size - The size of each page
Source

pub fn fragmentainer_count(&self) -> usize

Get the number of fragmentainers (pages, columns, etc.) in this context.

Source

pub fn current(&self) -> &Fragmentainer

Get a reference to the current fragmentainer being filled.

Source

pub fn current_mut(&mut self) -> &mut Fragmentainer

Get a mutable reference to the current fragmentainer being filled.

Source

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

pub fn fragmentainers(&self) -> Vec<&Fragmentainer>

Get all fragmentainers in this context.

Source

pub fn page_size(&self) -> Option<LogicalSize>

Get the page size for paged media, or None for other contexts.

Source

pub fn page_content_height(&self) -> f32

Get the page content height (page height minus margins). For continuous media, returns f32::MAX.

Source

pub fn is_paged(&self) -> bool

Check if this is paged media.

Trait Implementations§

Source§

impl Clone for FragmentationContext

Source§

fn clone(&self) -> FragmentationContext

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 FragmentationContext

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.
Source§

impl<G1, G2> Within<G2> for G1
where G2: Contains<G1>,

Source§

fn is_within(&self, b: &G2) -> bool