Skip to main content

RenderDocument

Trait RenderDocument 

Source
pub trait RenderDocument: Send {
    // Required methods
    fn page_count(&self) -> u32;
    fn page(&self, index: u32) -> Result<RenderPage, RenderError>;
    fn limits(&self) -> &RenderLimits;
    fn render(
        &self,
        request: &RenderRequest,
        out: &mut [u8],
        cancel: &CancelToken,
    ) -> Result<TilePlan, RenderError>;

    // Provided method
    fn plan(&self, request: &RenderRequest) -> Result<TilePlan, RenderError> { ... }
}
Expand description

One open document. Send but not Sync: one call at a time on a document. A backend whose engine isn’t thread-safe (PDFium) also serialises calls across its documents.

Added in 0.2.0.

Required Methods§

Source

fn page_count(&self) -> u32

The number of pages.

Added in 0.2.0.

Source

fn page(&self, index: u32) -> Result<RenderPage, RenderError>

Page index’s displayed size and /Rotate (ADR 0027: 0-based).

§Errors

page-index-out-of-range, data-pending, render-failed.

Added in 0.2.0.

Source

fn limits(&self) -> &RenderLimits

The limits this document was opened with.

Added in 0.2.0.

Source

fn render( &self, request: &RenderRequest, out: &mut [u8], cancel: &CancelToken, ) -> Result<TilePlan, RenderError>

Renders request into out, which must hold exactly TilePlan::byte_len bytes, in straight-alpha RGBA8. Checks cancel before and after the engine call (a running single-threaded render can’t see a cancel, ADR 0004 §1).

§Errors

As RenderDocument::plan, plus invalid-argument for a wrong buffer size, render-failed and cancelled.

Added in 0.2.0.

Provided Methods§

Source

fn plan(&self, request: &RenderRequest) -> Result<TilePlan, RenderError>

Validates request for this document: the tile geometry and the bytes it needs.

§Errors

As RenderDocument::page, plus TilePlan::new’s.

Added in 0.2.0.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§