screencapturekit/cm/
frame_status.rs

1//! Frame status for captured screen content
2
3use std::fmt;
4
5/// Frame status for captured screen content
6///
7/// Indicates the state of a frame captured by `ScreenCaptureKit`.
8/// This maps to Apple's `SCFrameStatus` enum.
9#[repr(i32)]
10#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
11pub enum SCFrameStatus {
12    /// Frame contains complete content
13    #[default]
14    Complete = 0,
15    /// Frame is idle (no changes)
16    Idle = 1,
17    /// Frame is blank
18    Blank = 2,
19    /// Frame is suspended
20    Suspended = 3,
21    /// Started (first frame)
22    Started = 4,
23    /// Stopped (last frame)
24    Stopped = 5,
25}
26
27impl SCFrameStatus {
28    /// Create from raw i32 value
29    pub const fn from_raw(value: i32) -> Option<Self> {
30        match value {
31            0 => Some(Self::Complete),
32            1 => Some(Self::Idle),
33            2 => Some(Self::Blank),
34            3 => Some(Self::Suspended),
35            4 => Some(Self::Started),
36            5 => Some(Self::Stopped),
37            _ => None,
38        }
39    }
40
41    /// Returns true if the frame contains actual content
42    pub const fn has_content(self) -> bool {
43        matches!(self, Self::Complete | Self::Started)
44    }
45
46    /// Returns true if the frame is complete
47    pub const fn is_complete(self) -> bool {
48        matches!(self, Self::Complete)
49    }
50}
51
52impl fmt::Display for SCFrameStatus {
53    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
54        match self {
55            Self::Complete => write!(f, "Complete"),
56            Self::Idle => write!(f, "Idle"),
57            Self::Blank => write!(f, "Blank"),
58            Self::Suspended => write!(f, "Suspended"),
59            Self::Started => write!(f, "Started"),
60            Self::Stopped => write!(f, "Stopped"),
61        }
62    }
63}