async-io-model
БесплатноБез исполняемых скриптовНе проверенUse when writing or changing code that returns IOResult or keeps I/O state across yields - state machines, re-entrancy, CompletionGroup
от tursodatabase★ 25 410 звёзд на GitHubОб этом скилле
Async I/O model
Turso uses cooperative yielding with explicit state machines instead of async/await.
Types
pub enum IOResult<T> {
Done(T), // finished, here is the result
IO(IOCompletions), // wait for the completion, then call again
}
pub struct IOCompletions(pub Completion);
pub type IOResultOr<T> = Result<IOResult<T>, Box<LimboError>>;
A function returning IOResult is called repeatedly until it returns Done.
To wait for several completions, add them to a CompletionGroup and yield the built completion. It finishes when all complete or one fails, can be nested, and can be cancelled with group.cancel():
let mut group = CompletionGroup::new(|_| {});
group.add(&completion1);
group.add(&completion2);
io_yield_one!(group.build());
Macros
return_if_io!(expr)unwrapsDone(v)tovand returns theIOvariant to the caller.io_yield_one!(c)returnsOk(IOResult::IO(IOCompletions(c))).
State machines
Keep progress in a state enum, loop on it, and set the next state before each yield:
loop {
match &mut self.state {
State::Start => {
let (page, completion) = start_read();
self.state = State::WaitingForRead { page };
io_yield_one!(completion);
}
State::WaitingForRead { page } => {
let data = page.get_contents().to_vec();
self.state = State::Processing { data };
}
State::Processing { data } => return Ok(IOResult::Done(process(data))),
}
}
If a field is used in only one or two states, put it in those variants. Other states then cannot access it, and the flow is easier to follow. Loop indexes belong in the variant too (ProcessingItem { idx, items }), advanced only when changing state.
Re-entrancy
When a call yields, the caller waits and then calls the function again from the top. Any state changed before the yield is changed again on the second call:
self.counter += 1; // runs on every re-entry
return_if_io!(something_that_might_yield());
Do the change after the yield returns, or move to a new state before yielding and make the change in that state:
return_if_io!(something_that_might_yield());
self.counter += 1; // reached once
Typical bugs: vec.push(x), idx += 1, or map.insert(k, v) before a return_if_io! repeat on each re-entry.
Установить async-io-model в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл async-io-model?
Use when writing or changing code that returns IOResult or keeps I/O state across yields - state machines, re-entrancy, CompletionGroup
Как установить скилл async-io-model?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл async-io-model запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic