← ClaudeAtlas

ffi-error-progress-cancellisted

Use when you design or review an FFI boundary for a long-running Rust operation that must report typed errors, stream progress, and cancel cooperatively - import, indexing, preview, render, export, or any job longer than one frame. Covers a closed versioned boundary error taxonomy, UniFFI flat error enums, mapping stable error codes to native UX buckets, redaction so no backtrace or filesystem path crosses the boundary, callback-interface progress listeners carrying job id plus stage and fraction, bridges to Kotlin Flow with callbackFlow and awaitClose and to Swift AsyncThrowingStream with onTermination, and wiring coroutine cancel and Task cancel down to an idempotent non-blocking cancel_job. Triggers on flat_error, callback interface, callbackFlow, awaitClose, trySend, AsyncThrowingStream, CancellationException, CancellationError, cancel_job, job_id, progress event, or "the UI must not show stack traces".
po4yka/rust-skills · ★ 0 · Web & Frontend · score 75
Install: claude install-skill po4yka/rust-skills
# FFI error, progress, and cancellation ## Purpose Own the end-to-end contract that crosses the FFI boundary for every long-running operation: a stable error taxonomy, a progress event stream, and cooperative cancellation. These three concerns are one contract. If you design them separately, you get an error enum that cannot express "the user pressed Cancel", a progress stream that leaks a worker thread when the consumer goes away, and a cancel call that blocks the UI thread. This skill covers the boundary UX. Related skills cover the parts underneath: - `uniffi-boundary` - binding generation mechanics and UDL/proc-macro shape. - `memory-model` - the exact atomic `Ordering` for the cancel flag and the progress counter. - `rust-panic-safety` and `rust-discipline` - panic policy at the boundary. - `rust-debugging` - panic propagation through generated bindings. - `rust-observability` - the `tracing` subscriber that receives redacted events. - `rust-jni` - the same three protocols over a hand-written JNI boundary. ## When to use - You design or review an FFI method that takes measurable time: archive import, index build, preview generation, large or vector export, batch export, asset import. - You map a core error enum to the flat boundary enum, then on to Kotlin exceptions and Swift `Error`. - You bridge a Rust progress callback into a Kotlin `Flow` or a Swift `AsyncThrowingStream`. - You wire coroutine cancellation or `Task` cancellation down to a Rust job ca