euv_ui/component/camera/hook/struct.rs
1use crate::*;
2
3/// Reactive state for the camera, including camera control,
4/// facing mode, and QR code scanning results.
5#[derive(Clone, Copy, Data, Debug, Eq, New, PartialEq)]
6pub struct UseEuvCamera {
7 /// Whether the camera stream is currently open.
8 pub camera_open: Signal<bool>,
9 /// Whether the camera is in the process of opening.
10 pub camera_loading: Signal<bool>,
11 /// The current error message, empty if no error.
12 pub error_message: Signal<String>,
13 /// The current camera facing direction (front or rear).
14 pub facing: Signal<EuvCameraFacing>,
15 /// The last QR code scan result text.
16 pub scan_result: Signal<String>,
17 /// The interval handle for the periodic QR code scan timer.
18 pub scan_handle: Signal<Option<IntervalHandle>>,
19}
20
21/// Configuration for camera initialization.
22#[derive(Clone, CustomDebug)]
23pub struct EuvCameraConfig {
24 /// The CSS selector for the video element.
25 pub video_selector: &'static str,
26 /// The scan interval in milliseconds.
27 pub scan_interval_millis: i32,
28 /// Whether to auto-start QR scanning when camera opens.
29 pub auto_scan: bool,
30 /// Callback when a QR code is detected.
31 #[debug(skip)]
32 pub on_qr_detected: Option<QrDetectedCallback>,
33 /// Callback when camera error occurs.
34 #[debug(skip)]
35 pub on_error: Option<CameraErrorCallback>,
36}