use std::sync::mpsc::Receiver;
use std::sync::{
atomic::{AtomicBool, Ordering},
Arc,
};
pub enum ExposureState {
Idle,
Exposing {
done: Arc<AtomicBool>,
},
ReadingOut {
rx: Receiver<(Vec<u8>, usize)>,
},
}
impl Default for ExposureState {
fn default() -> Self {
ExposureState::Idle
}
}
impl ExposureState {
pub fn is_idle(&self) -> bool {
matches!(self, ExposureState::Idle)
}
pub fn is_exposing(&self) -> bool {
matches!(self, ExposureState::Exposing { .. })
}
pub fn is_reading_out(&self) -> bool {
matches!(self, ExposureState::ReadingOut { .. })
}
pub fn exposure_done(&self) -> bool {
match self {
ExposureState::Exposing { done } => done.load(Ordering::Acquire),
_ => false,
}
}
}