- Home
- Skills
- Huiali
- Rust Skills
- Rust Web
rust-web_skill
- Shell
20
GitHub Stars
3
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill huiali/rust-skills --skill rust-web- SKILL_EN.md1.8 KB
- SKILL_ZH.md6.9 KB
- SKILL.md13.4 KB
Overview
This skill is a Rust web development expert focused on HTTP frameworks (axum, actix), REST design, handler patterns, state management, middleware, database integration, and domain-driven architecture. It provides concise patterns, trade-offs, and recommended workflows to design and audit production-ready Rust web services. The guidance emphasizes type-safe handlers, shared state, error handling, and scalable project structure.
How this skill works
The skill inspects project needs (performance, ergonomics, prototyping) and recommends an appropriate framework, with axum as the general default and actix-web for high-performance requirements. It maps common HTTP inputs to extractor patterns, shows how to manage shared state safely with Arc and connection pools, and provides middleware, error, and database integration patterns. It also prescribes a domain-driven folder layout and a review checklist to validate readiness for production.
When to use it
- Starting a new service where modern Tokio integration and ergonomics matter → choose axum.
- Building a latency-critical, throughput-heavy endpoint → consider actix-web.
- Prototyping quickly with minimal config → use a developer-friendly framework.
- When handlers need typed path/query/body extraction and compile-time safety.
- When you need consistent error-to-HTTP mapping and centralized middleware.
Best practices
- Use extractors (Path, Query, Json, State) to keep handlers explicit and type-safe.
- Share configuration and pools via a Clone + Send + Sync + 'static AppState using Arc.
- Define a domain-specific ApiError enum and implement IntoResponse for uniform responses.
- Use connection pooling (sqlx::PgPool) and transactions for multi-step operations.
- Instrument logging with tracing, add CORS and body limits, and implement graceful shutdown.
Example use cases
- Designing a CRUD REST API with typed request/response DTOs and consistent error mapping.
- Refactoring a monolith into domain modules with well-defined ports and repositories.
- Adding authentication and request logging via reusable middleware layers.
- Integrating Postgres with sqlx, using transactions for creation flows and connection tuning.
- Optimizing performance by adding compression, caching headers, and tuning pool sizes.
FAQ
Choose axum for most projects for ergonomics and Tokio integration; use actix-web when absolute performance is required.
How should I share database and config across handlers?
Create an AppState struct holding PgPool and Arc<Config>, ensure it implements Clone and use State extractor.