use thiserror::Error;
#[derive(Clone)]
pub struct Frame {
pub width: u32,
pub height: u32,
pub bgra: Vec<u8>,
}
#[derive(Debug, Clone, Error)]
pub enum CaptureError {
#[error(
"camera access denied — grant Camera permission \
(on macOS, run inside an app bundle with NSCameraUsageDescription)"
)]
AccessDenied,
#[error("no camera matched that id")]
NotFound,
#[error("camera produced no frame in time")]
Timeout,
#[error("camera resources are unavailable; another application may be using the camera")]
ResourcesUnavailable,
#[error("capture setup failed: {0}")]
Setup(String),
#[error("camera capture is not implemented on this platform")]
Unsupported,
}
#[cfg(test)]
mod tests {
use super::CaptureError;
#[test]
fn resources_unavailable_does_not_assert_another_application_owns_the_camera() {
assert_eq!(
CaptureError::ResourcesUnavailable.to_string(),
"camera resources are unavailable; another application may be using the camera"
);
}
}