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 unsafe `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`] | Contains supported callback and panic-payload failures, with explicit cleanup before best-effort destruction |
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.** Completion contexts are exact-live and one-shot.
23//! Their atomic consumed flags only reject duplicates while the backing
24//! allocation remains live; they do not validate dangling raw pointers.
25//! - **Panic-safe.** `extern "C"` callbacks pass through [`panic_safe`]
26//! wrappers. Explicit cleanup runs before opaque destruction; multiple
27//! destructor panics within one aggregate remain outside the contract.
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;