一键导入
async-programming
Master Rust async/await with Tokio. Use when implementing async operations, spawning tasks, using channels, or handling timeouts.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Master Rust async/await with Tokio. Use when implementing async operations, spawning tasks, using channels, or handling timeouts.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Create or update a release version entry in version.md. Use when drafting a new version, cutting a release, or when the user asks to create or update release notes.
Application overview for frename. Use when: orienting to the project for the first time, deciding which crate or module to touch, understanding what the app does end-to-end, looking up where a concept lives (tags, files, ordering, colors), or understanding keyboard shortcuts and the tag/file lifecycle.
Core development guide for frename-core. Use when: adding or changing traits (StoredTagStore, AppStateStore), modifying TagList logic, working with OrderedCollection, adding Tag fields, changing FileSnapshot/FileTagger, writing core tests, or adding database schema/migrations.
Image preview implementation guide for frename. Use when: adding or changing the media_viewer feature, working with FileKind classification, changing how FolderWorkspace opens files, adding JPEG or HEIC/HEIF decoding, understanding the no-unload path for images, or moving video_player into media_viewer.
UI + core combination guide for frename. Use when: wiring a new feature that spans both UI state and core data, deciding where logic lives (core vs UI), connecting a new message to a core operation, changing how file workspace or folder workspace coordinates with TagList or AppDatabase, or understanding the data flow between a user action and disk write.
Undo/redo implementation guide for frename. Use when: implementing the undo infrastructure in frename-core, adding a new undoable command, wiring Ctrl+Z/Ctrl+Y in the UI, or understanding how History, UndoContext, and commands interact.
| name | async-programming |
| description | Master Rust async/await with Tokio. Use when implementing async operations, spawning tasks, using channels, or handling timeouts. |
Master Rust's asynchronous programming with async/await and Tokio.
# Cargo.toml
[dependencies]
tokio = { version = "1", features = ["full"] }
use tokio;
#[tokio::main]
async fn main() {
let result = fetch_data().await;
println!("{:?}", result);
}
async fn fetch_data() -> String {
tokio::time::sleep(tokio::time::Duration::from_secs(1)).await;
"Data fetched".to_string()
}
use tokio;
#[tokio::main]
async fn main() {
// Spawn concurrent task
let handle = tokio::spawn(async {
expensive_operation().await
});
// Do other work...
// Wait for result
let result = handle.await.unwrap();
}
// Run multiple futures concurrently
let (r1, r2, r3) = tokio::join!(
fetch_user(1),
fetch_user(2),
fetch_user(3),
);
// Race futures - first to complete wins
tokio::select! {
result = operation_a() => println!("A: {:?}", result),
result = operation_b() => println!("B: {:?}", result),
}
use tokio::time::{timeout, Duration};
match timeout(Duration::from_secs(5), slow_operation()).await {
Ok(result) => println!("Completed: {:?}", result),
Err(_) => println!("Timed out"),
}
use tokio::sync::mpsc;
let (tx, mut rx) = mpsc::channel(32);
tokio::spawn(async move {
tx.send("message").await.unwrap();
});
while let Some(msg) = rx.recv().await {
println!("Got: {}", msg);
}
use std::sync::Arc;
use tokio::sync::Mutex;
let data = Arc::new(Mutex::new(0));
let data_clone = Arc::clone(&data);
tokio::spawn(async move {
let mut lock = data_clone.lock().await;
*lock += 1;
});
use reqwest;
#[tokio::main]
async fn main() -> Result<(), reqwest::Error> {
let response = reqwest::get("https://api.example.com/data")
.await?
.json::<serde_json::Value>()
.await?;
println!("{:?}", response);
Ok(())
}