fractal/components/camera/
mod.rs#[cfg(target_os = "linux")]
mod linux;
mod qrcode_scanner;
mod viewfinder;
pub(crate) use self::qrcode_scanner::QrCodeScanner;
use self::{
qrcode_scanner::QrVerificationDataBoxed,
viewfinder::{
CameraViewfinder, CameraViewfinderExt, CameraViewfinderImpl, CameraViewfinderState,
},
};
cfg_if::cfg_if! {
if #[cfg(target_os = "linux")] {
pub(crate) type Camera = linux::LinuxCamera;
} else {
pub(crate) type Camera = unimplemented::UnimplementedCamera;
}
}
pub trait CameraExt {
async fn has_cameras() -> bool;
async fn viewfinder() -> Option<CameraViewfinder>;
}
#[cfg(not(target_os = "linux"))]
mod unimplemented {
#[derive(Debug)]
pub(crate) struct UnimplementedCamera;
impl CameraExt for UnimplementedCamera {
async fn has_cameras() -> bool {
false
}
async fn viewfinder() -> Option<CameraViewfinder> {
tracing::error!("The camera API is not supported on this platform");
None
}
}
}