#[derive(Clone)]
pub struct Frame {
pub width: u32,
pub height: u32,
pub bgra: Vec<u8>,
}
#[derive(Debug, Clone)]
pub enum CaptureError {
AccessDenied,
NotFound,
Timeout,
Setup(String),
Unsupported,
}
impl std::fmt::Display for CaptureError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::AccessDenied => write!(
f,
"camera access denied — grant Camera permission (on macOS, run inside an app bundle with NSCameraUsageDescription)"
),
Self::NotFound => write!(f, "no camera matched that id"),
Self::Timeout => write!(f, "camera produced no frame in time"),
Self::Setup(s) => write!(f, "capture setup failed: {s}"),
Self::Unsupported => write!(f, "camera capture is not implemented on this platform"),
}
}
}
impl std::error::Error for CaptureError {}