pub struct RenderSession<'a> {
pub caches: Option<&'a mut RenderCaches>,
pub visible: Option<&'a Visibility>,
pub deadline: Option<&'a Deadline>,
}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.