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//! | [`cf`] | Core Foundation value, collection, locale, formatter, and runtime wrappers | — |
14//! | [`raw`] | Exhaustive low-level CoreFoundation/CoreMedia/CoreVideo/IOSurface/Dispatch bindings | — |
15//! | [`cg`] | CoreGraphics value types + bitmap drawing wrappers | `cg` |
16//! | [`iosurface`] | `IOSurface` (zero-copy GPU buffers) | `iosurface` |
17//! | [`dispatch_queue`] | Grand Central Dispatch | `dispatch` |
18//! | [`cm`] | `CoreMedia` time / sample / buffer wrappers | `cm` |
19//! | [`cv`] | `CoreVideo` pixel-buffer wrappers | `cv` |
20//! | [`utils`] | shared FFI helpers (always on) | — |
21//!
22//! # Architecture
23//!
24//! ```text
25//! Safe Rust API (CGRect, CGContext, IOSurface, DispatchQueue, ...)
26//! ├── exhaustive raw bindings (src/raw)
27//! ├── direct Apple framework FFI (src/cg/mod.rs)
28//! └── Swift @_cdecl bridge FFI (src/ffi/mod.rs)
29//! └── swift-bridge/Sources/...
30//! └── Apple Core* frameworks
31//! ```
32
33#![cfg_attr(docsrs, feature(doc_cfg))]
34#![allow(clashing_extern_declarations)]
35
36mod error;
37
38pub mod cf;
39pub mod ffi;
40pub mod raw;
41pub mod utils;
42
43pub use error::CFError;
44
45#[cfg(feature = "cg")]
46#[cfg_attr(docsrs, doc(cfg(feature = "cg")))]
47pub mod cg;
48
49#[cfg(feature = "iosurface")]
50#[cfg_attr(docsrs, doc(cfg(feature = "iosurface")))]
51pub mod iosurface;
52
53#[cfg(feature = "dispatch")]
54#[cfg_attr(docsrs, doc(cfg(feature = "dispatch")))]
55pub mod dispatch_queue;
56
57#[cfg(feature = "cm")]
58#[cfg_attr(docsrs, doc(cfg(feature = "cm")))]
59pub mod cm;
60
61#[cfg(feature = "cv")]
62#[cfg_attr(docsrs, doc(cfg(feature = "cv")))]
63pub mod cv;
64
65pub use utils::FourCharCode;
66
67/// Common imports for users of this crate.
68pub mod prelude {
69 pub use crate::cf::{CFArray, CFString, CFType, CFURL};
70 #[cfg(feature = "cg")]
71 pub use crate::cg::{CGPoint, CGRect, CGSize};
72 #[cfg(feature = "cm")]
73 pub use crate::cm::{CMBlockBuffer, CMFormatDescription, CMSampleBuffer, CMTime, CMTimeRange};
74 #[cfg(feature = "cv")]
75 pub use crate::cv::{
76 CVBuffer, CVImageBuffer, CVMetalTextureCache, CVPixelBuffer, CVPixelBufferLockFlags,
77 };
78 #[cfg(feature = "dispatch")]
79 pub use crate::dispatch_queue::{
80 DispatchGroup, DispatchQoS, DispatchQueue, DispatchSemaphore, DispatchSource,
81 };
82 #[cfg(feature = "iosurface")]
83 pub use crate::iosurface::{IOSurface, IOSurfaceLockOptions};
84 pub use crate::utils::FourCharCode;
85}