Skip to main content

CustomViewRenderer

Trait CustomViewRenderer 

Source
pub trait CustomViewRenderer: 'static {
    // Required method
    fn render_to_rgba(
        &self,
        view: AnyView,
        size: RenderSize,
    ) -> impl Future<Output = RenderResult>;
}
Expand description

Trait for custom view renderers.

Native backends implement this to provide view-to-RGBA capture. The method returns impl Future, so implementations write a plain async fn — the object-safe boxing needed to store the renderer in the Environment is an internal detail of ViewRenderer, never part of this contract.

Required Methods§

Source

fn render_to_rgba( &self, view: AnyView, size: RenderSize, ) -> impl Future<Output = RenderResult>

Render a view to RGBA bytes.

The implementation should:

  1. Create an offscreen rendering context at the given size
  2. Render the view hierarchy (native widgets + GPU surfaces)
  3. Capture the final composited result to RGBA pixels
  4. Return the pixel data

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§