doom-fish-utils
Framework-agnostic FFI utilities shared by every safe-Rust Apple-SDK binding in the doom-fish family.
What's in here
| Module | Purpose |
|---|---|
completion |
Sync + async completion handlers for callback-based FFI APIs. Provides AsyncCompletion<T> and SyncCompletion<T> with AtomicBool double-fire guards. |
ffi_string |
Helpers for retrieving owned Strings from buffer-writing or pointer-returning C / Swift APIs, with RAII-driven dealloc. |
four_char_code |
FourCharCode newtype (used by pixel formats, OSType codes, AudioToolbox, VideoToolbox, etc.). |
panic_safe |
panic_safe(...) wrapper for extern "C" callbacks so a Rust panic doesn't unwind into Swift / C code. |
stream |
BoundedAsyncStream<T> — executor-agnostic, bounded, lossy-by-default async stream lifted from the screencapturekit-rs AsyncSCStream pattern. Generic over any item type. |
Design tenets
- Executor-agnostic. No tokio / async-std / smol dependencies; works
anywhere
std::future::Futureworks. - Defence in depth. The async completion path uses an
AtomicBoolconsumedflag to prevent double-fire UAF in the face of misbehaving Swift callbacks. - Panic-safe.
extern "C"callbacks pass throughpanic_safewrappers so an unexpected Rust panic logs and returns rather than unwinding into Swift / C code.
Optional features
futures-stream— adds afutures_core::Streamimpl onBoundedAsyncStream<T>so the stream can be used directly withfutures::StreamExt/tokio_stream.
Stability
This crate is the foundation of every doom-fish Apple-SDK binding crate. Breaking changes ship as major version bumps; minor versions add modules or non-breaking helpers.
License
Dual-licensed under MIT OR Apache-2.0.