visual-cortex-capture 0.2.0

Screen-capture abstraction for visual-cortex: frames, regions, rates, the FrameSource trait, and the macOS ScreenCaptureKit backend.
Documentation
/// What to capture: a display by index, or a window matched by exact title.
///
/// Construction is infallible — a matching window need not exist yet (it may
/// appear later and reattach). Resolution failure surfaces at capture time as
/// [`CaptureError::TargetNotFound`](crate::CaptureError::TargetNotFound).
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Target {
    /// The Nth display reported by the platform (0 = first).
    Display(usize),
    /// The first window whose title matches exactly.
    WindowTitled(String),
}

impl Target {
    /// Capture the display at `index` (0 = first).
    pub fn display(index: usize) -> Self {
        Target::Display(index)
    }

    /// Capture the first window whose title exactly equals `title`.
    pub fn window_titled(title: impl Into<String>) -> Self {
        Target::WindowTitled(title.into())
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn constructors_build_expected_variants() {
        assert_eq!(Target::display(2), Target::Display(2));
        assert_eq!(
            Target::window_titled("Elden Ring"),
            Target::WindowTitled("Elden Ring".to_string())
        );
    }
}