Skip to main content

Camera

Trait Camera 

Source
pub trait Camera: Send + Sync {
    // Required methods
    fn start(&self) -> Result<String, CameraError>;
    fn latest_frame(&self) -> Option<CameraFrame>;
    fn stop(&self);

    // Provided method
    fn capture_still(&self) -> Option<CameraStill> { ... }
}
Expand description

A running (or startable) live camera. Implementations are Send + Sync so a background preview pump can start/stop and poll frames off the UI thread.

Required Methods§

Source

fn start(&self) -> Result<String, CameraError>

Start the capture session, returning a human-readable device name. Safe to call again while already running (idempotent).

Source

fn latest_frame(&self) -> Option<CameraFrame>

The most recent frame, or None if none has arrived yet.

Source

fn stop(&self)

Stop the session and release the device.

Provided Methods§

Source

fn capture_still(&self) -> Option<CameraStill>

Capture a full-resolution still through the platform photo pipeline.

Blocks up to a few seconds while the device exposes and encodes. Returns None where the backend has no dedicated photo path (callers should fall back to latest_frame) or when the capture fails.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§