Skip to main content

apple_cf/
lib.rs

1//! `apple-cf` — safe, dependency-free Rust bindings for Apple's shared
2//! Core* frameworks.
3//!
4//! This crate is the foundation of the doom-fish macOS Rust suite. It exists
5//! so framework-agnostic types like [`cg::CGRect`], [`iosurface::IOSurface`],
6//! and [`DispatchQueue`] don't have to be re-vendored by every crate that
7//! builds on top of `CMSampleBuffer`/`CVPixelBuffer`/etc.
8//!
9//! # Modules
10//!
11//! | Module | Framework | Feature flag |
12//! |---|---|---|
13//! | [`cg`] | CoreGraphics value types | `cg` |
14//! | [`iosurface`] | IOSurface (zero-copy GPU buffers) | `iosurface` |
15//! | [`dispatch_queue`] | Grand Central Dispatch | `dispatch` |
16//! | [`utils`] | shared FFI helpers (always on) | — |
17//!
18//! Future frameworks (CoreMedia, CoreVideo, Metal) will be added as separate
19//! features so that downstream crates only pull in what they need.
20//!
21//! # Architecture
22//!
23//! ```text
24//! Safe Rust API (CGRect, IOSurface, DispatchQueue, ...)
25//!     └── extern "C" FFI declarations (src/ffi/mod.rs)
26//!             └── Swift @_cdecl bridge (swift-bridge/Sources/...)
27//!                     └── Apple Core* frameworks
28//! ```
29
30#![cfg_attr(docsrs, feature(doc_cfg))]
31
32pub mod ffi;
33pub mod utils;
34
35#[cfg(feature = "cg")]
36#[cfg_attr(docsrs, doc(cfg(feature = "cg")))]
37pub mod cg;
38
39#[cfg(feature = "iosurface")]
40#[cfg_attr(docsrs, doc(cfg(feature = "iosurface")))]
41pub mod iosurface;
42
43#[cfg(feature = "dispatch")]
44#[cfg_attr(docsrs, doc(cfg(feature = "dispatch")))]
45pub mod dispatch_queue;
46
47#[cfg(feature = "cm")]
48#[cfg_attr(docsrs, doc(cfg(feature = "cm")))]
49pub mod cm;
50
51#[cfg(feature = "cv")]
52#[cfg_attr(docsrs, doc(cfg(feature = "cv")))]
53pub mod cv;
54
55pub use utils::FourCharCode;
56
57/// Common imports for users of this crate.
58pub mod prelude {
59    #[cfg(feature = "cg")]
60    pub use crate::cg::{CGPoint, CGRect, CGSize};
61    #[cfg(feature = "cm")]
62    pub use crate::cm::{CMBlockBuffer, CMFormatDescription, CMSampleBuffer, CMTime};
63    #[cfg(feature = "cv")]
64    pub use crate::cv::{CVPixelBuffer, CVPixelBufferLockFlags};
65    #[cfg(feature = "dispatch")]
66    pub use crate::dispatch_queue::{DispatchQoS, DispatchQueue};
67    #[cfg(feature = "iosurface")]
68    pub use crate::iosurface::{IOSurface, IOSurfaceLockOptions};
69    pub use crate::utils::FourCharCode;
70}