用途:面向 Rust 1.92+ 的开发技能,聚焦高性能、内存安全应用,覆盖 Axum、Tokio、SQLx 等技术栈。自动触发条件包括 .rs、Cargo.toml、async/await、Tokio、Axum、SQLx、serde、lifetimes、traits。
主要能力:支持高性能 REST API 与微服务、内存安全并发系统、CLI 工具与系统实用程序、WebAssembly 应用、低延迟网络服务。涵盖 Rust 2024 Edition、稳定版 async traits、const generics、let-else、改进的借用检查器(polonius)。
使用方式:在 Cargo.toml 中添加 axum 0.8、tokio 1.48(full features)、tower-http 0.6(cors、trace)。用 Router 链式注册路由并 with_state 共享状态,绑定 TcpListener 后调用 axum::serve。SQLx 使用 query_as! 宏做编译期检查查询,配合 FromRow 派生与事务 begin/commit。Serde 通过 Serialize/Deserialize 派生及 rename_all 等属性控制序列化。错误处理用 thiserror 派生 Error 并实现 IntoResponse。CLI 用 clap 派生 Parser 与 Subcommand。测试使用 cfg(test) 与 tokio::test。
性能与部署:release 配置可启用 lto、codegen-units=1、panic=abort、strip。部署可用多阶段 Dockerfile(rust alpine 构建、alpine 运行)。并发限流可用 Arc 包裹 Semaphore 配合 join_all。
限制与说明:资料未提供具体收费、价格与平台信息。常见问题处理包括 cargo clean、cargo build、rustc --version、cargo update、cargo tree、cargo sqlx prepare。资料给出的性能特征为启动 50-100ms、基础内存 5-20MB、吞吐 100k-200k req/s、p99 小于 5ms、容器 5-15MB(alpine),这些为资料陈述,未提供独立验证。