Skip to main content

cbf_chrome/bridge/
mod.rs

1//! FFI bridge adapters between Rust-side models and `cbf-chrome-sys` C ABI types.
2//!
3//! This module handles low-level IPC event decoding and conversion utilities
4//! that remain internal to the crate boundary.
5
6mod client;
7mod event;
8mod map;
9mod utils;
10
11pub(crate) use client::IpcEventWaitHandle;
12pub use client::{EventWaitResult, IpcClient};
13pub use event::IpcEvent;
14
15/// Convert native NSEvent input to CBF input events on macOS.
16#[cfg(target_os = "macos")]
17pub use map::{
18    convert_nsevent_to_chrome_key_event, convert_nsevent_to_chrome_mouse_event,
19    convert_nsevent_to_chrome_mouse_wheel_event, convert_nsevent_to_key_event,
20    convert_nsevent_to_mouse_event, convert_nsevent_to_mouse_wheel_event,
21    convert_nspasteboard_to_drag_data,
22};
23
24/// Errors that can occur in the `cbf-chrome-sys` (`cbf_bridge`) layer.
25#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
26pub enum BridgeError {
27    /// Failed to load the runtime bridge library or one of its required symbols.
28    #[error("failed to load the runtime bridge library")]
29    BridgeLoadFailed,
30    /// Bridge state was invalid for the requested operation.
31    #[error("invalid bridge state")]
32    InvalidState,
33    /// Bridge returned an invalid IPC channel argument during channel setup.
34    #[error("bridge returned an invalid IPC channel argument")]
35    InvalidChannelArgument,
36    /// Failed to connect to the IPC channel.
37    #[error("failed to connect to the IPC channel")]
38    ConnectionFailed,
39    /// Failed to authenticate the Chromium bridge session.
40    #[error("failed to authenticate bridge session")]
41    AuthenticationFailed,
42    /// A bridge operation failed.
43    #[error("bridge operation failed: {operation}")]
44    OperationFailed { operation: &'static str },
45    /// Input data was invalid for the FFI layer.
46    #[error("invalid input for the FFI layer")]
47    InvalidInput,
48    /// An IPC event could not be parsed.
49    #[error("failed to parse IPC event")]
50    InvalidEvent,
51}