Skip to main content

RenderSession

Struct RenderSession 

Source
pub struct RenderSession<'a> {
    pub caches: Option<&'a mut RenderCaches>,
    pub visible: Option<&'a Visibility>,
    pub deadline: Option<&'a Deadline>,
    pub cancel: Option<&'a Deadline>,
    pub region: Region,
}
Expand description

What one render call may reuse or restrict, beyond the page and the options.

A plain record with Default, so a caller names only the parts it has: RenderSession { caches: Some(&mut caches), ..Default::default() }. Both fields are absent by default and both defaults are the conservative answer — fresh caches, nothing hidden — which is why render_page can be the whole API for a caller who wants neither.

It carries borrows rather than owning anything: the caches outlive the call by construction (that is what they are for), and the visibility tree belongs to the pre-pass that computed it.

Fields§

§caches: Option<&'a mut RenderCaches>

Caches to reuse across calls, instead of a fresh set per page: a caller rendering many pages of one document flattens each glyph outline once for the run rather than once per page.

§Determinism

Type-3 blue-zone snapping is order-dependent by design (see RenderCaches), so a page rendered with a warm cache can differ by a snapped pixel from one rendered cold. Reuse across pages of one document is intended; reusing caches across unrelated documents makes output depend on what was rendered before. For a byte-identical baseline, leave this None.

§visible: Option<&'a Visibility>

Which objects optional content leaves visible. None draws them all.

It comes from pdfrum_page::page_visibility, a pre-pass over the same page with the document’s /OCProperties. Splitting it out is what keeps the render API free of a resolver: deciding visibility needs indirect-object lookup and a mutable evaluation cache, and consuming the answer needs neither — it is one index per object.

§deadline: Option<&'a Deadline>

When the render must have stopped. None — the default — is no limit.

Read once before the target is allocated and once per object during the walk (nested lists included), so a page that has run out of time stops at the next object; the render then fails with Error::Limit rather than returning a pixmap with the rest of the page missing. Costs one branch per object when unset. A borrow, like the other two: the caller’s Limits owns it.

§cancel: Option<&'a Deadline>

A stop for this render alone. None — the default — is none.

Read exactly as deadline is, and either passing ends the render with Error::Limit. The difference is who owns it: the document’s deadline outlives every render and, once passed, stays passed, while a cancel is made for one call and dropped with it, so a viewer abandoning a stale tile raises it and the next render starts clean.

§region: Region

How much of the page to draw. Region::Whole by default.

With Region::Rect the pixmap is exactly the rectangle’s size and each of its pixels is the pixel a whole-page render has there; the whole page is never allocated. See Region.

Trait Implementations§

Source§

impl<'a> Debug for RenderSession<'a>

Source§

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

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

impl<'a> Default for RenderSession<'a>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<'a> !UnwindSafe for RenderSession<'a>

§

impl<'a> Freeze for RenderSession<'a>

§

impl<'a> RefUnwindSafe for RenderSession<'a>

§

impl<'a> Send for RenderSession<'a>

§

impl<'a> Sync for RenderSession<'a>

§

impl<'a> Unpin for RenderSession<'a>

§

impl<'a> UnsafeUnpin for RenderSession<'a>

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.