Skip to main content

doom_fish_utils/
lib.rs

1//! # doom-fish-utils
2//!
3//! Framework-agnostic FFI utilities shared by the doom-fish family of safe
4//! Rust bindings to Apple SDKs.
5//!
6//! ## Modules
7//!
8//! | Module | Purpose |
9//! |--------|---------|
10//! | [`completion`] | Sync and async completion handlers for FFI callbacks |
11//! | [`ffi_callbacks`] | Common `extern "C"` callback type aliases shared across bridge crates |
12//! | [`ffi_string`] | Owned-string helpers around heap-allocated C strings |
13//! | [`four_char_code`] | `FourCharCode` wrapper (used by pixel formats, `OSType` codes, etc.) |
14//! | [`panic_safe`] | Catches panics inside `extern "C"` callbacks so they don't unwind across the FFI boundary |
15//! | [`spsc`] | Lock-free single-producer single-consumer rings for real-time callback → async-consumer handoff |
16//! | [`stream`] | Executor-agnostic bounded async streams (waker + `VecDeque` + lossy oldest-drop policy) |
17//!
18//! ## Design tenets
19//!
20//! - **Executor-agnostic.** No tokio / async-std / smol dependencies; works
21//!   anywhere `std::future::Future` works.
22//! - **Defence in depth.** The async completion path uses an `AtomicBool`
23//!   `consumed` flag to prevent double-fire UAF in the face of misbehaving
24//!   Swift callbacks.
25//! - **Panic-safe.** `extern "C"` callbacks pass through [`panic_safe`]
26//!   wrappers so an unexpected Rust panic logs and returns rather than
27//!   unwinding into Swift / C code.
28//!
29//! ## Stability
30//!
31//! This crate is the foundation of every doom-fish Apple-SDK binding crate.
32//! Breaking changes ship as major version bumps; minor versions add modules
33//! or non-breaking helpers.
34
35#![doc(html_root_url = "https://docs.rs/doom-fish-utils/0.3.0")]
36#![cfg_attr(docsrs, feature(doc_cfg))]
37
38pub mod completion;
39pub mod ffi_callbacks;
40pub mod ffi_string;
41pub mod four_char_code;
42pub mod panic_safe;
43pub mod spsc;
44pub mod stream;
45
46pub use four_char_code::FourCharCode;