systems-programming-rust-project - SKILL

发布时间:2026/11/25 6:18:03

systems-programming-rust-project - SKILL name: systems-programming-rust-projectdescription: “You are a Rust project architecture expert specializing in scaffolding production-ready Rust applications. Generate complete project structures with cargo tooling, proper module organization, testing”risk: criticalsource: communitydate_added: “2026-02-27”Rust 项目脚手架您是专注于搭建生产级 Rust 应用的 Rust 项目架构专家。按照 Rust 最佳实践生成包含 cargo 工具、正确的模块组织、测试设置和配置的完整项目结构。使用此技能的场景处理 Rust 项目脚手架相关的任务或工作流需要 Rust 项目脚手架方面的指导、最佳实践或检查清单不要使用此技能的场景任务与 Rust 项目脚手架无关您需要此范围之外的其他领域或工具背景用户需要自动化的 Rust 项目脚手架以创建符合习惯用法、安全且高性能的应用并具备正确的结构、依赖管理、测试和构建配置。重点关注 Rust 习惯用法和可扩展架构。需求$ARGUMENTS说明1. 分析项目类型根据用户需求确定项目类型二进制CLI 工具、应用、服务库可复用的 crate、共享工具工作区多 crate 项目、monorepoWeb APIActix/Axum Web 服务、REST APIWebAssembly基于浏览器的应用2. 使用 Cargo 初始化项目# 创建二进制项目cargonew project-namecdproject-name# 或创建库cargonew--liblibrary-name# 初始化 gitcargo 会自动执行# 如需可添加到 .gitignoreecho/target.gitignoreechoCargo.lock.gitignore# 仅适用于库3. 生成二进制项目结构binary-project/ ├── Cargo.toml ├── README.md ├── src/ │ ├── main.rs │ ├── config.rs │ ├── cli.rs │ ├── commands/ │ │ ├── mod.rs │ │ ├── init.rs │ │ └── run.rs │ ├── error.rs │ └── lib.rs ├── tests/ │ ├── integration_test.rs │ └── common/ │ └── mod.rs ├── benches/ │ └── benchmark.rs └── examples/ └── basic_usage.rsCargo.toml[package] name project-name version 0.1.0 edition 2021 rust-version 1.75 authors [Your Name emailexample.com] description Project description license MIT OR Apache-2.0 repository https://github.com/user/project-name [dependencies] clap { version 4.5, features [derive] } tokio { version 1.36, features [full] } anyhow 1.0 serde { version 1.0, features [derive] } serde_json 1.0 [dev-dependencies] criterion 0.5 [[bench]] name benchmark harness false [profile.release] opt-level 3 lto true codegen-units 1src/main.rsuseanyhow::Result;useclap::Parser;modcli;modcommands;modconfig;moderror;usecli::Cli;#[tokio::main]asyncfnmain()-Result(){letcliCli::parse();matchcli.command{cli::Commands::Init(args)commands::init::execute(args).await?,cli::Commands::Run(args)commands::run::execute(args).await?,}Ok(())}src/cli.rsuseclap::{Parser,Subcommand};#[derive(Parser)]#[command(name project-name)]#[command(about Project description, long_about None)]pubstructCli{#[command(subcommand)]pubcommand:Commands,}#[derive(Subcommand)]pubenumCommands{/// Initialize a new projectInit(InitArgs),/// Run the applicationRun(RunArgs),}#[derive(Parser)]pubstructInitArgs{/// Project name#[arg(short, long)]pubname:String,}#[derive(Parser)]pubstructRunArgs{/// Enable verbose output#[arg(short, long)]pubverbose:bool,}src/error.rsusestd::fmt;#[derive(Debug)]pubenumAppError{NotFound(String),InvalidInput(String),IoError(std::io::Error),}implfmt::DisplayforAppError{fnfmt(self,f:mutfmt::Formatter)-fmt::Result{matchself{AppError::NotFound(msg)write!(f,Not found: {},msg),AppError::InvalidInput(msg)write!(f,Invalid input: {},msg),AppError::IoError(e)write!(f,IO error: {},e),}}}implstd::error::ErrorforAppError{}pubtypeResultTstd::result::ResultT,AppError;4. 生成库项目结构library-name/ ├── Cargo.toml ├── README.md ├── src/ │ ├── lib.rs │ ├── core.rs │ ├── utils.rs │ └── error.rs ├── tests/ │ └── integration_test.rs └── examples/ └── basic.rs库的 Cargo.toml[package] name library-name version 0.1.0 edition 2021 rust-version 1.75 [dependencies] # 库应保持最小依赖 [dev-dependencies] tokio-test 0.4 [lib] name library_name path src/lib.rssrc/lib.rs//! Library documentation//!//! # Examples//!//! //! use library_name::core::CoreType;//!//! let instance CoreType::new();//! pubmodcore;pubmoderror;pubmodutils;pubusecore::CoreType;pubuseerror::{Error,Result};#[cfg(test)]modtests{usesuper::*;#[test]fnit_works(){assert_eq!(22,4);}}5. 生成工作区结构workspace/ ├── Cargo.toml ├── .gitignore ├── crates/ │ ├── api/ │ │ ├── Cargo.toml │ │ └── src/ │ │ └── lib.rs │ ├── core/ │ │ ├── Cargo.toml │ │ └── src/ │ │ └── lib.rs │ └── cli/ │ ├── Cargo.toml │ └── src/ │ └── main.rs └── tests/ └── integration_test.rsCargo.toml工作区根[workspace] members [ crates/api, crates/core, crates/cli, ] resolver 2 [workspace.package] version 0.1.0 edition 2021 rust-version 1.75 authors [Your Name emailexample.com] license MIT OR Apache-2.0 [workspace.dependencies] tokio { version 1.36, features [full] } serde { version 1.0, features [derive] } [profile.release] opt-level 3 lto true6. 生成 Web API 结构Axumweb-api/ ├── Cargo.toml ├── src/ │ ├── main.rs │ ├── routes/ │ │ ├── mod.rs │ │ ├── users.rs │ │ └── health.rs │ ├── handlers/ │ │ ├── mod.rs │ │ └── user_handler.rs │ ├── models/ │ │ ├── mod.rs │ │ └── user.rs │ ├── services/ │ │ ├── mod.rs │ │ └── user_service.rs │ ├── middleware/ │ │ ├── mod.rs │ │ └── auth.rs │ └── error.rs └── tests/ └── api_tests.rsWeb API 的 Cargo.toml[package] name web-api version 0.1.0 edition 2021 [dependencies] axum 0.7 tokio { version 1.36, features [full] } tower 0.4 tower-http { version 0.5, features [trace, cors] } serde { version 1.0, features [derive] } serde_json 1.0 sqlx { version 0.7, features [runtime-tokio-native-tls, postgres] } tracing 0.1 tracing-subscriber 0.3src/main.rsAxumuseaxum::{Router,routing::get};usetower_http::cors::CorsLayer;usestd::net::SocketAddr;modroutes;modhandlers;modmodels;modservices;moderror;#[tokio::main]asyncfnmain(){tracing_subscriber::fmt::init();letappRouter::new().route(/health,get(routes::health::health_check)).nest(/api/users,routes::users::router()).layer(CorsLayer::permissive());letaddrSocketAddr::from(([0,0,0,0],3000));tracing::info!(Listening on {},addr);letlistenertokio::net::TcpListener::bind(addr).await.unwrap();axum::serve(listener,app).await.unwrap();}7. 配置开发工具Makefile.PHONY: build test lint fmt run clean bench build: cargo build test: cargo test lint: cargo clippy -- -D warnings fmt: cargo fmt --check run: cargo run clean: cargo clean bench: cargo benchrustfmt.tomledition 2021 max_width 100 tab_spaces 4 use_small_heuristics Maxclippy.tomlcognitive-complexity-threshold 30输出格式项目结构符合 Rust 习惯用法的完整目录树配置包含依赖和构建设置的 Cargo.toml入口点带有正确文档的 main.rs 或 lib.rs测试单元测试和集成测试结构文档README 和代码文档开发工具Makefile、clippy/rustfmt 配置专注于创建符合习惯用法的 Rust 项目具有强类型安全、正确的错误处理和全面的测试设置。局限性仅当任务明确匹配上述范围时才使用此技能。不要将输出视为针对特定环境验证、测试或专家审查的替代品。如果缺少所需输入、权限、安全边界或成功标准请停下来询问澄清。
延伸阅读

更多相关文章

2026/11/25 6:18:01

tanstack-query-expert - SKILL

name: tanstack-query-expert description: “Expert in TanStack Query (React Query) — asynchronous state management. Covers data fetching, stale time configuration, mutations, optimistic updates, and Next.js App Router (SSR) integration.” risk: safe source…

2026/11/22 11:00:57

API开放平台重构实践:Java17+Vue3打造灵钥系统

这几年我做API网关和开放平台类的项目不算少,但真正让我下决心把整套技术栈推倒重来的,还是这个API灵钥系统。简单说,灵钥系统就是管理API Key的“管家”,在过去它只是给内部服务发钥匙、验钥匙,如今要改造成一个面向多…

2026/11/22 11:00:31

终端零信任:从“边界防御”到“端点免疫”的演进之路

前言 在红蓝对抗和渗透测试中,攻击者攻陷一台普通办公终端往往只是起点。拿到权限后,通过扫描、凭证窃取、协议漏洞等方式横向移动,逐步逼近核心资产——这是大多数攻击事件的真实写照。传统安全模型默认“内网可信”,一旦边界被突…

2026/11/25 6:17:15

广西考电工证用的教材官方回应实操考试心里没底怕挂科

广西考电工证用的教材官方回应实操考试心里没底怕挂科 你是不是也这样,一想到要参加电工证实操考试,就心里打鼓,担心自己能不能过?别急,今天咱们就来聊聊 广西考电工证用的教材 ,以及 官方回应 下的备考和考试经验,帮你把这关过了。…

2026/11/25 6:17:14

淄博淄川培训电工证怎么选不被坑?网上查询教你避坑

淄博淄川培训电工证怎么选不被坑?网上查询教你避坑 你是不是正愁不知道去哪报名淄博淄川培训电工证?怕被中介坑了钱还拿不到证?别急,这篇文章告诉你怎么通过 网上查询 找到靠谱的培训机构,还能了解电工证的考试流程、证书价值、复审要求和避坑技巧。…

2026/11/25 6:17:14

怎么从网上领取电工证 想上岗找工作先拿电子证书

怎么从网上领取电工证 想上岗找工作先拿电子证书 你现在缺的就是一个 电工证 ,不然连工地的门都进不去。你是不是也在网上到处找“怎么从网上领取电工证”?别急,我来给你说清楚,现在电工证基本都换成了 电子证书 ,而且你得知道怎么去拿,怎么用。…

2026/11/25 6:17:14

机构办理电工证套路培训机构怎么选

电工证过期了不知道怎么复审延期?河南2026最新政策全解析 证书过期了不知道怎么复审延期,这事儿真的让人头疼。我认识的平顶山老李,就是因为在2025年没及时处理电工证复审,结果被工地临时叫停了工作,损失了几个月的收入。现在到了2026年,河…

2026/11/25 6:17:14

亦庄学习电工证在哪考?别怕考不过白交培训费,看这篇全搞定

亦庄学习电工证在哪考?别怕考不过白交培训费,看这篇全搞定 怕考不过白交培训费?别急,这波你得先搞明白【亦庄学习电工证在哪考】,再考虑要不要报名。特别是像你这样在开封做中小施工企业的负责人,考个电工证不是为了“摆设”,而是为了能合规施工、拿项…

2026/11/25 6:12:14

工厂电工证需要什么?在哪考?别怕考不过白交培训费

工厂电工证需要什么?在哪考?别怕考不过白交培训费 你是不是正愁着 工厂电工证需要什么 ,怕自己花冤枉钱、走弯路?又或者,你已经交了培训费,但不知道 在哪考 ,心里没底?别急,我来给你讲明白,带你一步一步把证拿到手,不再踩坑!…

2026/11/24 13:09:03

高压电工证还能年审吗良心建议来了,学历不高也能考!

高压电工证还能年审吗良心建议来了,学历不高也能考! 你是不是也担心,自己学历不高,根本报不上高压电工证?其实不然,现在政策已经非常明确, 高压电工证还能年审 ,而且只要符合条件, 学历不是门槛 , 良心建议…

2026/11/24 13:02:07

吴江的电工证免费培训怎么报名?官方报名入口全解析

吴江的电工证免费培训怎么报名?官方报名入口全解析 你急需特种作业证才能上岗找工作,但不知道从哪里下手?别急,现在就给你讲明白【吴江的电工证免费培训】到底怎么操作,以及怎么通过 官方报名入口…

2026/11/24 0:40:30

电工证复审肃州区的真实经历:别被中介坑了,自己搞定更靠谱

电工证复审肃州区的真实经历:别被中介坑了,自己搞定更靠谱 不知道去哪报名怕被中介坑?这几乎是每个需要办理或复审电工证的人的真实经历。尤其在肃州区,信息不透明、流程复杂、中介收费高又不靠谱,让很多电工从业者感到头疼。作为一个在应急管理和特种作…

2026/11/25 0:04:22

阳泉电工证考试内容怎么考?工地太忙根本没时间复习考试

阳泉电工证考试内容怎么考?工地太忙根本没时间复习考试 工地太忙根本没时间复习考试,很多电工工友都在头疼这个问题。尤其是像阳泉地区,施工进度紧、任务重,一不小心就错过了电工证的考试准备时间。如果你也正在为阳泉电工证考试内容发愁,或者想了解…

2026/11/25 0:04:24

永州电工证在哪里查询通过率揭秘:怕考不过白交培训费?

永州电工证在哪里查询通过率揭秘:怕考不过白交培训费? 你是不是也担心考电工证白交培训费?特别是像永州电工证在哪里查询这种问题,很多学员一上来就问,到底能不能顺利拿到证?其实这背后隐藏着一个 通过率揭秘…

2026/11/23 21:10:55

面向复杂光照与角度的宠物面部识别鲁棒性增强策略

在智慧养宠时代,基于视觉的宠物身份识别技术正逐步从实验室走向家庭应用。然而,与配合度高的人类不同,宠物是典型的“非合作生物识别对象”——它们不会主动配合摄像头调整姿态,更无法控制光照环境。实际应用中,我们常…

2026/11/24 9:14:05

SSM电子书店源码全解析:结构、原理、部署与排错实战

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

还想了解更多?直接咨询顾问

免费诊断 + 免费方案 + 透明报价。

全国咨询热线400-8866-253
免费获取方案
☎咨询二维码 ☎ ↑