用途:作为 Rust 1.92+ 开发专家技能,用于构建高性能、内存安全的应用程序,覆盖异步 Web 服务、并发系统、CLI 工具、WebAssembly 与低延迟网络服务。触发信号包括 .rs、Cargo.toml、async/await、Tokio、Axum、SQLx、serde、lifetimes、traits。
主要能力:涵盖 Rust 2024 Edition、稳定版 async trait、const generics、let-else、改进的借用检查器;Web 框架 Axum 0.8(Router、with_state、CorsLayer、axum::serve);异步运行时 Tokio 1.48(tokio::spawn、mpsc、select! 超时);数据库 SQLx 0.8(query_as! 编译期检查、FromRow、事务);序列化 Serde 1.0;错误处理 thiserror 与 IntoResponse;CLI 使用 clap;测试使用 tokio::test。
使用方式:在 Cargo.toml 添加 axum 0.8、tokio 1.48(full features)、tower-http 0.6(cors、trace);用 PgPoolOptions 连接 DATABASE_URL,构建 Router 并绑定 TcpListener 后调用 axum::serve。发布构建可启用 lto、codegen-units=1、panic=abort、strip。部署可用多阶段 Dockerfile 生成 alpine 镜像。
适用场景:高性能 REST API 与微服务、内存安全并发系统、CLI 与系统工具、WebAssembly 应用、低延迟网络服务。
限制与说明:资料未提供收费、价格与平台信息;性能数据(启动 50-100ms、内存 5-20MB、吞吐 100k-200k req/s、p99 小于 5ms、容器 5-15MB)来自资料原文,实际表现可能因环境而异。常见问题可用 cargo clean、cargo update、cargo tree、cargo sqlx prepare 排查。