本文へスキップ

Workers-rs

トレンドメンテナンス中
cloudflare/workers-rs

Cloudflare Workers の公式 Rust SDK。Rust と WebAssembly で高性能なサーバーレスアプリケーションを構築できます。

GitHub で見る
スター
3547
フォーク
418
ウォッチ
3547
未解決の Issue
174

この紹介文は現在英語版のみです。

Workers-rs

Workers-rs is the official Rust SDK for Cloudflare Workers, allowing developers to write and deploy Workers using Rust and WebAssembly. This SDK provides a seamless experience for building high-performance serverless applications with the safety and performance benefits of Rust.

Core Features

  • Rust-First Development: Write Workers entirely in Rust
  • WebAssembly Output: Compiles to WebAssembly for optimal performance
  • Type Safety: Leverage Rust’s strong type system
  • Workers Runtime API: Complete access to Workers runtime features
  • Middleware Support: Built-in middleware system
  • Ergonomic Macros: Simplified Worker development with proc macros
  • HTTP Integration: First-class support for HTTP requests and responses

Quick Start

  1. Prerequisites:

    # Install Rust
    curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
    
    # Install wrangler
    npm install -g wrangler
  2. Create a New Project:

    wrangler generate my-worker https://github.com/cloudflare/workers-rs/templates/worker
    cd my-worker
  3. Development:

    wrangler dev
  4. Deployment:

    wrangler deploy

Example Worker

use worker::*;

#[event(fetch)]
pub async fn main(req: Request, env: Env, _ctx: worker::Context) -> Result<Response> {
    Response::ok("Hello from Rust!")
}

Key Components

  • Worker Runtime: Complete Rust bindings for the Workers runtime
  • HTTP Types: Ergonomic types for HTTP handling
  • Environment Bindings: Access to Workers KV, R2, and other services
  • Router: Built-in routing system
  • Middleware: Extensible middleware framework
  • WebAssembly: Optimized WASM compilation

Use Cases

  • High-performance API endpoints
  • Complex data processing
  • WebAssembly-powered applications
  • CPU-intensive tasks
  • Security-critical applications
  • Edge computing solutions

Advanced Features

  • KV Storage: Native bindings for Workers KV
  • R2 Storage: Interface with R2 object storage
  • Durable Objects: State management with DO support
  • Fetch API: Complete HTTP client functionality
  • Crypto Operations: Access to Web Crypto API
  • Custom Domains: Domain management support
  • Scheduled Tasks: Cron trigger support

Development Tools

  • wrangler: CLI tool for development and deployment
  • console_error_panic_hook: Better error messages
  • wasm-bindgen: WebAssembly bindings generation
  • workerd: Local development environment

Community and Support

License

This project is licensed under the Apache License 2.0.

共通のカテゴリとタグで順位付けした、似たオープンソースプロジェクトです。

すべての Web フレームワークプロジェクト →