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_string`] | Owned-string helpers around heap-allocated C strings |
12//! | [`four_char_code`] | `FourCharCode` wrapper (used by pixel formats, `OSType` codes, etc.) |
13//! | [`panic_safe`] | Catches panics inside `extern "C"` callbacks so they don't unwind across the FFI boundary |
14//! | [`stream`] | Executor-agnostic bounded async streams (waker + `VecDeque` + lossy oldest-drop policy) |
15//!
16//! ## Design tenets
17//!
18//! - **Executor-agnostic.** No tokio / async-std / smol dependencies; works
19//! anywhere `std::future::Future` works.
20//! - **Defence in depth.** The async completion path uses an `AtomicBool`
21//! `consumed` flag to prevent double-fire UAF in the face of misbehaving
22//! Swift callbacks.
23//! - **Panic-safe.** `extern "C"` callbacks pass through [`panic_safe`]
24//! wrappers so an unexpected Rust panic logs and returns rather than
25//! unwinding into Swift / C code.
26//!
27//! ## Stability
28//!
29//! This crate is the foundation of every doom-fish Apple-SDK binding crate.
30//! Breaking changes ship as major version bumps; minor versions add modules
31//! or non-breaking helpers.
32
33#![doc(html_root_url = "https://docs.rs/doom-fish-utils/0.1.1")]
34#![cfg_attr(docsrs, feature(doc_cfg))]
35
36pub mod completion;
37pub mod ffi_string;
38pub mod four_char_code;
39pub mod panic_safe;
40pub mod stream;
41
42pub use four_char_code::FourCharCode;