apple-cf
Safe, dependency-free Rust bindings for Apple's shared Core* frameworks — the foundation underneath the doom-fish macOS Rust suite.
Status: experimental. Carved out of
screencapturekit-rs; more frameworks (CoreMedia, CoreVideo, Metal) will land in subsequent releases.
What's in the box
| Module | Framework | Feature flag | Status |
|---|---|---|---|
cg |
CoreGraphics value types (CGRect, CGPoint, CGSize) |
cg |
✅ |
iosurface |
IOSurface (zero-copy GPU buffers, multi-planar formats) | iosurface |
✅ |
dispatch_queue |
Grand Central Dispatch queues + QoS | dispatch |
✅ |
cm |
CoreMedia (CMSampleBuffer, CMTime, CMBlockBuffer, CMFormatDescription) |
cm |
✅ |
cv |
CoreVideo (CVPixelBuffer, CVPixelBufferPool) |
cv |
✅ |
utils |
Shared FFI helpers (always on) | — | ✅ |
metal |
Metal (MTLDevice, MTLTexture) |
metal |
🚧 planned |
Why this crate exists
Every doom-fish crate that wraps a media-adjacent Apple framework needs the same primitives — CGRect, CVPixelBuffer, IOSurface, dispatch queues. Instead of re-vendoring those inside every crate (and drifting), this crate owns them once.
┌────────────────────────────────────────────────────────────┐
│ screencapturekit / videotoolbox / avfoundation / vision │
│ ↓ depends on ↓ │
│ ┌────────────────────────────────────────────────────────┐ │
│ │ apple-cf (this crate) │ │
│ └────────────────────────────────────────────────────────┘ │
│ ↓ Swift @_cdecl bridge ↓ │
│ Apple Core* frameworks │
└────────────────────────────────────────────────────────────┘
Requirements
- macOS 13.0+
- Xcode toolchain (Swift 5.9+); Command Line Tools alone is not enough —
xcrun --sdk macosx --show-sdk-versionmust succeed - Apple Silicon or Intel Mac
Installation
[]
= "0.1"
Or pick only the frameworks you need:
[]
= { = "0.1", = false, = ["cg", "iosurface"] }
Quick examples
Allocate an IOSurface and write a pixel
use ;
#
Create a custom dispatch queue
use ;
let q = new;
Work with CGRect
use CGRect;
let r = new;
assert_eq!;
Architecture
This crate uses the same Swift-bridge pattern as the rest of the doom-fish crates:
swift-bridge/Sources/<Framework>Bridge/exposes a thin@_cdeclC surfacesrc/ffi/mod.rsdeclares the matchingextern "C"bindingssrc/<framework>/provides the safe Rust API on top
The Rust crate has zero runtime dependencies.
Roadmap
- CoreMedia —
CMSampleBuffer,CMTime,CMFormatDescription,CMBlockBuffer(carve out from screencapturekit-rs, leavingSCStreamFrameInfoattachment readers in place upstream) - CoreVideo —
CVPixelBuffer,CVPixelBufferPool - Metal —
MTLDevice,MTLTexture,MTLCommandQueue - CoreFoundation — opt-in basic types if needed by downstream crates
Migrating screencapturekit-rs to consume apple-cf is the proof point that closes this story.
License
Licensed under either of Apache-2.0 or MIT at your option.