async-io-model

Installation
Summary

Cooperative async patterns using explicit state machines, completions, and re-entrancy safeguards for Turso's I/O model.

  • Core types: IOResult<T> (returns Done or IO requiring re-call) and Completion for tracking individual operations
  • CompletionGroup aggregates multiple completions into one, with nesting and cancellation support
  • State machine pattern encodes progress in enum variants to safely handle re-entry across yield points
  • Critical pitfall: mutating shared state before yield points causes bugs on re-entry; mutations must occur after yields or within state transitions
  • Helper macros return_if_io! and io_yield_one! simplify propagation and yielding logic
SKILL.md

Async I/O Model Guide

Turso uses cooperative yielding with explicit state machines instead of Rust async/await.

Core Types

pub enum IOCompletions {
    Single(Completion),
}

#[must_use]
pub enum IOResult<T> {
    Done(T),      // Operation complete, here's the result
    IO(IOCompletions),  // Need I/O, call me again after completions finish
}

Functions returning IOResult must be called repeatedly until Done.

Related skills
Installs
604
GitHub Stars
18.7K
First Seen
Jan 28, 2026