fractal/components/camera/
mod.rs1#[cfg(target_os = "linux")]
4mod linux;
5mod qrcode_scanner;
6mod viewfinder;
7
8pub(crate) use self::qrcode_scanner::QrCodeScanner;
9use self::{
10 qrcode_scanner::QrVerificationDataBoxed,
11 viewfinder::{
12 CameraViewfinder, CameraViewfinderExt, CameraViewfinderImpl, CameraViewfinderState,
13 },
14};
15
16cfg_if::cfg_if! {
17 if #[cfg(target_os = "linux")] {
18 pub(crate) type Camera = linux::LinuxCamera;
20 } else {
21 pub(crate) type Camera = unimplemented::UnimplementedCamera;
23 }
24}
25
26pub trait CameraExt {
28 async fn has_cameras() -> bool;
30
31 async fn viewfinder() -> Option<CameraViewfinder>;
36}
37
38#[cfg(not(target_os = "linux"))]
40mod unimplemented {
41 use super::*;
42
43 #[derive(Debug)]
44 pub(crate) struct UnimplementedCamera;
45
46 impl CameraExt for UnimplementedCamera {
47 async fn has_cameras() -> bool {
48 false
49 }
50
51 async fn viewfinder() -> Option<CameraViewfinder> {
52 tracing::error!("The camera API is not supported on this platform");
53 None
54 }
55 }
56}