Skip to main content

Capture

Trait Capture 

Source
pub trait Capture {
    type Error;

    // Required method
    fn capture(&mut self) -> Result<Screenshot, Self::Error>;
}
Expand description

A self-contained screenshot source (e.g. a system capture session).

Implemented by providers that already hold everything needed to produce a screenshot on demand. Driver crates (miniscreenshot-wayland, miniscreenshot-x11, miniscreenshot-portal, …) implement this trait so they can be used interchangeably.

A blanket implementation is provided for FnMut() -> Result<Screenshot, E>, so free functions like miniscreenshot_wgpu::capture(&device, &queue, &texture) can be used as trait objects via a closure:

let mut cap = || miniscreenshot_wgpu::capture(&device, &queue, &texture);
take_and_save(&mut cap);

Required Associated Types§

Source

type Error

The error type returned when capture fails.

Required Methods§

Source

fn capture(&mut self) -> Result<Screenshot, Self::Error>

Capture a screenshot from this source.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl Capture for WgpuCapture<'_>

Source§

impl<F, E> Capture for F
where F: FnMut() -> Result<Screenshot, E>,

A blanket impl: any FnMut that returns Result<Screenshot, E> is a Capture. This removes the need for wrapper structs when the per-call state (device, queue, texture, surface, etc.) is captured in the closure body.

Source§

type Error = E