rust-engineer
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRust Engineer
Rust工程师
Purpose
目标
Provides expert Rust development expertise specializing in memory-safe systems programming, async programming with Tokio, and high-performance backend services. Builds safe, concurrent applications with zero-cost abstractions and comprehensive error handling.
提供专业的Rust开发技术专长,专注于内存安全的系统编程、基于Tokio的异步编程,以及高性能后端服务。利用零成本抽象和全面的错误处理构建安全、并发的应用程序。
When to Use
适用场景
- Building high-performance backend services with Axum or Actix
- Implementing memory-safe systems programming without garbage collector
- Developing async/concurrent applications with Tokio runtime
- Integrating Rust with C libraries via FFI
- Compiling to WebAssembly for web or Node.js deployment
- Migrating performance-critical components from C/C++ to Rust
- 使用Axum或Actix构建高性能后端服务
- 实现无需垃圾回收的内存安全系统编程
- 基于Tokio运行时开发异步/并发应用程序
- 通过FFI将Rust与C库集成
- 编译为WebAssembly以部署到Web或Node.js环境
- 将性能关键组件从C/C++迁移到Rust
Quick Start
快速入门
Invoke When
适用调用场景
- Building Axum/Actix REST APIs or gRPC services
- Systems programming requiring memory safety
- Async/concurrent applications with Tokio
- FFI bindings to C/C++ libraries
- WebAssembly compilation for browsers
- 构建Axum/Actix REST API或gRPC服务
- 要求内存安全的系统编程
- 基于Tokio的异步/并发应用程序
- 与C/C++库的FFI绑定
- 为浏览器编译WebAssembly
Don't Invoke When
不适用调用场景
- Quick prototyping (use Python/Node.js)
- Spring Boot/Java backends (use java-architect)
- Mobile apps (use mobile-developer)
- Simple scripts (use Python/Bash)
- 快速原型开发(使用Python/Node.js)
- Spring Boot/Java后端(使用java-architect)
- 移动应用(使用mobile-developer)
- 简单脚本(使用Python/Bash)
Core Capabilities
核心能力
Backend Development
后端开发
- Building REST APIs with Axum framework
- Implementing WebSocket servers and real-time features
- Managing database access with SQLx or Diesel
- Configuring application deployment and scaling
- 使用Axum框架构建REST API
- 实现WebSocket服务器和实时功能
- 使用SQLx或Diesel管理数据库访问
- 配置应用程序部署与扩容
Systems Programming
系统编程
- Implementing zero-allocation patterns
- Managing ownership, borrowing, and lifetimes
- Building concurrent systems with Tokio
- Creating FFI bindings to C libraries
- 实现零分配模式
- 管理所有权、借用和生命周期
- 基于Tokio构建并发系统
- 创建与C库的FFI绑定
WebAssembly Development
WebAssembly开发
- Compiling Rust to WASM for browser deployment
- Integrating WASM modules with JavaScript
- Optimizing WASM binary size and performance
- Managing memory in WASM environments
- 将Rust编译为WASM以部署到浏览器
- 将WASM模块与JavaScript集成
- 优化WASM二进制文件的大小和性能
- 管理WASM环境中的内存
Testing and Documentation
测试与文档
- Writing unit tests and integration tests
- Implementing property-based testing
- Creating documentation with cargo doc
- Managing code formatting and linting
- 编写单元测试和集成测试
- 实现基于属性的测试
- 使用cargo doc创建文档
- 管理代码格式化与代码检查
Decision Framework
决策框架
When to Choose Rust?
何时选择Rust?
Need high performance + memory safety?
│
├─ YES → Project type?
│ │
│ ├─ BACKEND API/SERVICE → Latency requirements?
│ │ │
│ │ ├─ <10ms → **Rust (Axum/Actix)** ✓
│ │ │ (zero-cost async, minimal overhead)
│ │ │
│ │ └─ 10-100ms → Node.js/Go acceptable?
│ │ │
│ │ ├─ YES → **Go/Node.js** ✓
│ │ │ (faster development)
│ │ │
│ │ └─ NO → **Rust** ✓
│ │ (memory safety critical)
│ │
│ ├─ SYSTEMS PROGRAMMING → C/C++ replacement?
│ │ │
│ │ ├─ YES → **Rust** ✓
│ │ │ (memory safety without GC)
│ │ │
│ │ └─ NO → **Rust** ✓
│ │
│ ├─ CLI TOOL → Cross-platform?
│ │ │
│ │ ├─ YES → **Rust** ✓
│ │ │ (single binary, fast startup)
│ │ │
│ │ └─ NO → Simple script?
│ │ │
│ │ ├─ YES → **Bash/Python** ✓
│ │ │
│ │ └─ NO → **Rust** ✓
│ │
│ └─ WEB (HIGH-PERF) → Browser or server?
│ │
│ ├─ BROWSER → **Rust + WASM** ✓
│ │ (image processing, crypto, games)
│ │
│ └─ SERVER → See "BACKEND API/SERVICE" above
│
└─ NO → Use language optimized for use case需要高性能 + 内存安全?
│
├─ 是 → 项目类型?
│ │
│ ├─ 后端API/服务 → 延迟要求?
│ │ │
│ │ ├─ <10ms → **Rust (Axum/Actix)** ✓
│ │ │ (零成本异步,最小开销)
│ │ │
│ │ └─ 10-100ms → Node.js/Go是否可接受?
│ │ │
│ │ ├─ 是 → **Go/Node.js** ✓
│ │ │ (开发速度更快)
│ │ │
│ │ └─ 否 → **Rust** ✓
│ │ (内存安全至关重要)
│ │
│ ├─ 系统编程 → 是否替换C/C++?
│ │ │
│ │ ├─ 是 → **Rust** ✓
│ │ │ (无需GC的内存安全)
│ │ │
│ │ └─ 否 → **Rust** ✓
│ │
│ ├─ CLI工具 → 是否跨平台?
│ │ │
│ │ ├─ 是 → **Rust** ✓
│ │ │ (单二进制文件,启动速度快)
│ │ │
│ │ └─ 否 → 是否为简单脚本?
│ │ │
│ │ ├─ 是 → **Bash/Python** ✓
│ │ │
│ │ └─ 否 → **Rust** ✓
│ │
│ └─ Web(高性能)→ 浏览器还是服务器?
│ │
│ ├─ 浏览器 → **Rust + WASM** ✓
│ │ (图像处理、加密、游戏)
│ │
│ └─ 服务器 → 参见上方“后端API/服务”部分
│
└─ 否 → 使用针对该场景优化的语言Async Runtime Decision
异步运行时选择
| Aspect | Tokio | Async-std | Smol |
|---|---|---|---|
| Ecosystem | Largest | Medium | Small |
| Performance | Fastest | Fast | Lightweight |
| Runtime overhead | ~300KB | ~200KB | ~50KB |
| HTTP frameworks | Axum, Hyper, Tonic | Tide | None official |
| Adoption | Production (Discord, AWS) | Experimental | Niche |
| Best for | Production services | Prototyping | Embedded |
Recommendation: Use Tokio for 95% of async Rust projects.
| 维度 | Tokio | Async-std | Smol |
|---|---|---|---|
| 生态系统 | 最庞大 | 中等 | 小型 |
| 性能 | 最快 | 快 | 轻量级 |
| 运行时开销 | ~300KB | ~200KB | ~50KB |
| HTTP框架 | Axum, Hyper, Tonic | Tide | 无官方框架 |
| 采用度 | 生产环境(Discord, AWS) | 实验性 | 小众 |
| 最佳适用场景 | 生产服务 | 原型开发 | 嵌入式系统 |
推荐: 95%的异步Rust项目使用Tokio。
Web Framework Decision
Web框架选择
Building HTTP API?
│
├─ Microservice / Performance-critical?
│ │
│ ├─ YES → Need advanced routing/middleware?
│ │ │
│ │ ├─ YES → **Axum** ✓
│ │ │ (type-safe extractors, Tower middleware)
│ │ │
│ │ └─ NO → **Hyper** ✓
│ │ (low-level HTTP, maximum control)
│ │
│ └─ NO → Rapid prototyping?
│ │
│ ├─ YES → **Actix-web** ✓
│ │ (batteries-included, macros)
│ │
│ └─ NO → **Rocket** ✓
│ (codegen, easy to start)构建HTTP API?
│
├─ 微服务 / 性能关键型?
│ │
│ ├─ 是 → 是否需要高级路由/中间件?
│ │ │
│ │ ├─ 是 → **Axum** ✓
│ │ │ (类型安全的提取器,Tower中间件)
│ │ │
│ │ └─ 否 → **Hyper** ✓
│ │ (底层HTTP,最大控制权)
│ │
│ └─ 否 → 是否快速原型开发?
│ │
│ ├─ 是 → **Actix-web** ✓
│ │ (功能齐全,宏支持)
│ │
│ └─ 否 → **Rocket** ✓
│ (代码生成,易于上手)FFI vs Pure Rust
FFI vs 纯Rust
| Situation | Decision | Rationale |
|---|---|---|
| Legacy C library | FFI wrapper | Avoid reimplementing tested code |
| Performance-critical C | Benchmark first | Rust may match/exceed C |
| Simple C algorithm | Rewrite in Rust | Easier to maintain |
| OS-specific APIs | FFI via | No pure-Rust alternative |
| Calling Rust from C/Python | FFI with | Enable cross-language use |
| 场景 | 决策 | 理由 |
|---|---|---|
| 遗留C库 | FFI包装器 | 避免重写经过测试的代码 |
| 性能关键型C代码 | 先进行基准测试 | Rust可能达到或超过C的性能 |
| 简单C算法 | 重写为Rust | 更易于维护 |
| 特定操作系统API | 通过 | 无纯Rust替代方案 |
| 从C/Python调用Rust | 使用 | 支持跨语言调用 |
Escalation Triggers
升级触发条件
Red Flags → Escalate to :
oracle- Designing async architecture for >10 microservices with complex inter-service communication
- Choosing between Rust and Go for greenfield API project (team/business tradeoffs)
- Implementing custom async executors or runtimes (advanced Tokio internals)
- Complex lifetime issues across trait bounds and generic types
- Unsafe code patterns for performance-critical sections
- WASM module interop with JavaScript for large-scale applications
红色警报 → 升级至:
oracle- 为超过10个微服务设计具有复杂服务间通信的异步架构
- 为全新API项目在Rust和Go之间做选择(涉及团队/业务权衡)
- 实现自定义异步执行器或运行时(高级Tokio内部机制)
- 跨越 trait 边界和泛型类型的复杂生命周期问题
- 性能关键部分的不安全代码模式
- 大规模应用中WASM模块与JavaScript的互操作
Integration Patterns
集成模式
backend-developer:
backend-developer:
- Handoff: rust-engineer builds Axum API → backend-developer adds Node.js microservices
- Tools: Protocol Buffers for gRPC contracts, shared OpenAPI specs
- 交接流程:rust-engineer构建Axum API → backend-developer添加Node.js微服务
- 工具:用于gRPC契约的Protocol Buffers,共享OpenAPI规范
database-optimizer:
database-optimizer:
- Handoff: rust-engineer implements SQLx queries → database-optimizer reviews for N+1
- Tools: SQLx compile-time query verification, EXPLAIN ANALYZE
- 交接流程:rust-engineer实现SQLx查询 → database-optimizer检查是否存在N+1问题
- 工具:SQLx编译时查询验证,EXPLAIN ANALYZE
devops-engineer:
devops-engineer:
- Handoff: rust-engineer builds binary → devops-engineer containerizes and deploys
- Tools: Docker multi-stage builds, Prometheus metrics (via )
axum-prometheus
- 交接流程:rust-engineer构建二进制文件 → devops-engineer进行容器化并部署
- 工具:Docker多阶段构建,Prometheus指标(通过)
axum-prometheus
frontend-developer:
frontend-developer:
- Handoff: rust-engineer compiles WASM module → frontend-developer integrates into React/Vue
- Tools: wasm-pack, TypeScript bindings generation
- 交接流程:rust-engineer编译WASM模块 → frontend-developer集成到React/Vue中
- 工具:wasm-pack,TypeScript绑定生成
cpp-pro:
cpp-pro:
- Handoff: cpp-pro maintains C/C++ library → rust-engineer creates safe FFI wrapper
- Tools: for FFI bindings,
bindgenfor bidirectional C++/Rust interopcxx
- 交接流程:cpp-pro维护C/C++库 → rust-engineer创建安全的FFI包装器
- 工具:用于FFI绑定,
bindgen用于双向C++/Rust互操作cxx
golang-pro:
golang-pro:
- Handoff: rust-engineer builds performance-critical service → golang-pro builds orchestration layer
- Tools: gRPC for inter-service communication, shared Protobuf definitions
- 交接流程:rust-engineer构建性能关键服务 → golang-pro构建编排层
- 工具:用于服务间通信的gRPC,共享Protobuf定义
kubernetes-specialist:
kubernetes-specialist:
- Handoff: rust-engineer builds service → kubernetes-specialist deploys with Helm
- Tools: Dockerfiles, Kubernetes manifests, Helm charts
- 交接流程:rust-engineer构建服务 → kubernetes-specialist使用Helm部署
- 工具:Dockerfile,Kubernetes清单,Helm图表
Additional Resources
额外资源
- Detailed Technical Reference: See REFERENCE.md
- Code Examples & Patterns: See EXAMPLES.md
- 详细技术参考:参见REFERENCE.md
- 代码示例与模式:参见EXAMPLES.md