car-desktop 0.9.0

OS-level screen capture, accessibility inspection, and input synthesis for Common Agent Runtime
Documentation
//! Windows backend for `car-desktop`.
//!
//! Q2 per docs/CAR_DESKTOP.md. In v1 this backend compiles clean on
//! every target but returns `CarDesktopError::PlatformUnsupported`
//! from every method — no `todo!()`, no `unimplemented!()`, no
//! silent no-ops.

use async_trait::async_trait;

use crate::backend::DesktopBackend;
use crate::errors::{CarDesktopError, Result};
use crate::models::{
    ClickRequest, DisplayId, Frame, KeyPressRequest, PermissionRequest, PermissionSnapshot,
    TypeRequest, UiMap, WindowFilter, WindowHandle, WindowInfo,
};

const PLATFORM: &str = "windows";

fn unsupported<T>() -> Result<T> {
    Err(CarDesktopError::PlatformUnsupported { platform: PLATFORM })
}

/// Inert backend returned on Windows targets. Shape matches the
/// macOS backend so consumers can swap platforms with no code
/// changes beyond the `Box<dyn DesktopBackend>` constructor.
pub struct WindowsBackend;

impl WindowsBackend {
    pub fn new() -> Self {
        Self
    }
}

impl Default for WindowsBackend {
    fn default() -> Self {
        Self::new()
    }
}

#[async_trait]
impl DesktopBackend for WindowsBackend {
    async fn list_windows(&self, _filter: WindowFilter) -> Result<Vec<WindowInfo>> {
        unsupported()
    }

    async fn observe_window(&self, _window: WindowHandle) -> Result<UiMap> {
        unsupported()
    }

    async fn capture_display(&self, _display: DisplayId) -> Result<Frame> {
        unsupported()
    }

    async fn focus_window(&self, _window: WindowHandle) -> Result<()> {
        unsupported()
    }

    async fn click(&self, _request: ClickRequest) -> Result<()> {
        unsupported()
    }

    async fn type_text(&self, _request: TypeRequest) -> Result<()> {
        unsupported()
    }

    async fn keypress(&self, _request: KeyPressRequest) -> Result<()> {
        unsupported()
    }

    async fn permissions(&self) -> Result<PermissionSnapshot> {
        unsupported()
    }

    async fn request_permissions(
        &self,
        _needs: PermissionRequest,
    ) -> Result<PermissionSnapshot> {
        unsupported()
    }
}