{"id":29228419,"url":"https://github.com/restatedev/sdk-rust","last_synced_at":"2025-10-24T13:52:01.258Z","repository":{"id":253789525,"uuid":"839942146","full_name":"restatedev/sdk-rust","owner":"restatedev","description":"Rust SDK for restate.dev","archived":false,"fork":false,"pushed_at":"2025-06-17T14:58:29.000Z","size":247,"stargazers_count":30,"open_issues_count":6,"forks_count":10,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-17T15:49:36.631Z","etag":null,"topics":["durable-execution","durable-functions","durable-objects","event-driven","workflows-as-code"],"latest_commit_sha":null,"homepage":"https://restate.dev/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/restatedev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-08-08T16:28:27.000Z","updated_at":"2025-06-17T14:58:32.000Z","dependencies_parsed_at":"2024-09-09T10:40:08.070Z","dependency_job_id":"0cd48d9f-278c-44bc-b5fc-fbf6fb54f2a4","html_url":"https://github.com/restatedev/sdk-rust","commit_stats":null,"previous_names":["restatedev/sdk-rust"],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/restatedev/sdk-rust","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/restatedev%2Fsdk-rust","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/restatedev%2Fsdk-rust/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/restatedev%2Fsdk-rust/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/restatedev%2Fsdk-rust/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/restatedev","download_url":"https://codeload.github.com/restatedev/sdk-rust/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/restatedev%2Fsdk-rust/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263305276,"owners_count":23445865,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["durable-execution","durable-functions","durable-objects","event-driven","workflows-as-code"],"created_at":"2025-07-03T10:10:54.387Z","updated_at":"2025-10-24T13:52:01.246Z","avatar_url":"https://github.com/restatedev.png","language":"Rust","readme":"[![Documentation](https://img.shields.io/docsrs/restate-sdk)](https://docs.rs/restate-sdk)\n[![crates.io](https://img.shields.io/crates/v/restate_sdk.svg)](https://crates.io/crates/restate-sdk/)\n[![Examples](https://img.shields.io/badge/view-examples-blue)](https://github.com/restatedev/examples)\n[![Discord](https://img.shields.io/discord/1128210118216007792?logo=discord)](https://discord.gg/skW3AZ6uGd)\n[![Twitter](https://img.shields.io/twitter/follow/restatedev.svg?style=social\u0026label=Follow)](https://twitter.com/intent/follow?screen_name=restatedev)\n\n# Restate Rust SDK\n\n[Restate](https://restate.dev/) is a system for easily building resilient applications using _distributed durable async/await_. This repository contains the Restate SDK for writing services using Rust.\n\n## Community\n\n- 🤗️ [Join our online community](https://discord.gg/skW3AZ6uGd) for help, sharing feedback and talking to the community.\n- 📖 [Check out our documentation](https://docs.restate.dev) to get quickly started!\n- 📣 [Follow us on Twitter](https://twitter.com/restatedev) for staying up to date.\n- 🙋 [Create a GitHub issue](https://github.com/restatedev/sdk-java/issues) for requesting a new feature or reporting a problem.\n- 🏠 [Visit our GitHub org](https://github.com/restatedev) for exploring other repositories.\n\n## Using the SDK\n\nAdd Restate and Tokio as dependencies:\n\n```toml\n[dependencies]\nrestate-sdk = \"0.1\"\ntokio = { version = \"1\", features = [\"full\"] }\n```\n\nThen you're ready to develop your Restate service using Rust:\n\n```rust\nuse restate_sdk::prelude::*;\n\n#[restate_sdk::service]\ntrait Greeter {\n    async fn greet(name: String) -\u003e HandlerResult\u003cString\u003e;\n}\n\nstruct GreeterImpl;\n\nimpl Greeter for GreeterImpl {\n    async fn greet(\u0026self, _: Context\u003c'_\u003e, name: String) -\u003e HandlerResult\u003cString\u003e {\n        Ok(format!(\"Greetings {name}\"))\n    }\n}\n\n#[tokio::main]\nasync fn main() {\n    // To enable logging/tracing\n    // tracing_subscriber::fmt::init();\n    HttpServer::new(\n        Endpoint::builder()\n            .with_service(GreeterImpl.serve())\n            .build(),\n    )\n    .listen_and_serve(\"0.0.0.0:9080\".parse().unwrap())\n    .await;\n}\n```\n\n## Running on Lambda\n\nThe Restate Rust SDK supports running services on AWS Lambda using Lambda Function URLs. This allows you to deploy your Restate services as serverless functions.\n\n### Setup\n\nFirst, enable the `lambda` feature in your `Cargo.toml`:\n\n```toml\n[dependencies]\nrestate-sdk = { version = \"0.1\", features = [\"lambda\"] }\ntokio = { version = \"1\", features = [\"full\"] }\n```\n\n### Basic Lambda Service\n\nHere's how to create a simple Lambda service:\n\n```rust\nuse restate_sdk::prelude::*;\n\n#[restate_sdk::service]\ntrait Greeter {\n    async fn greet(name: String) -\u003e HandlerResult\u003cString\u003e;\n}\n\nstruct GreeterImpl;\n\nimpl Greeter for GreeterImpl {\n    async fn greet(\u0026self, _: Context\u003c'_\u003e, name: String) -\u003e HandlerResult\u003cString\u003e {\n        Ok(format!(\"Greetings {name}\"))\n    }\n}\n\n#[tokio::main]\nasync fn main() {\n    // To enable logging/tracing\n    // check https://docs.aws.amazon.com/lambda/latest/dg/rust-logging.html#rust-logging-tracing\n\n    // Build and run the Lambda endpoint\n    LambdaEndpoint::run(\n        Endpoint::builder()\n            .bind(GreeterImpl.serve())\n            .build(),\n    )\n    .await\n    .unwrap();\n}\n```\n\n### Deployment\n\n1. Install `cargo-lambda`\n   ```\n   cargo install cargo-lambda\n   ```\n2. Build your Lambda function:\n\n   ```bash\n   cargo lambda build --release --arm64 --output-format zip\n   ```\n\n3. Create a Lambda function with the following configuration:\n\n   - **Runtime**: Amazon Linux 2023\n   - **Architecture**: arm64\n\n4. Upload your `zip` file to the Lambda function.\n\n### Logging\n\nThe SDK uses tokio's [`tracing`](https://docs.rs/tracing/latest/tracing/) crate to generate logs.\nJust configure it as usual through [`tracing_subscriber`](https://docs.rs/tracing-subscriber/latest/tracing_subscriber/) to get your logs.\n\n### Testing\n\nThe SDK uses [Testcontainers](https://rust.testcontainers.org/) to support integration testing using a Docker-deployed restate server.\nThe `restate-sdk-testcontainers` crate provides a framework for initializing the test environment, and an integration test example in `testcontainers/tests/test_container.rs`.\n\n```rust\n#[tokio::test]\nasync fn test_container() {\n    tracing_subscriber::fmt::fmt()\n        .with_max_level(tracing::Level::INFO) // Set the maximum log level\n        .init();\n\n    let endpoint = Endpoint::builder().bind(MyServiceImpl.serve()).build();\n\n    // simple test container intialization with default configuration\n    //let test_container = TestContainer::default().start(endpoint).await.unwrap();\n\n    // custom test container initialization with builder\n    let test_container = TestContainer::builder()\n        // optional passthrough logging from the resstate server testcontainer\n        // prints container logs to tracing::info level\n        .with_container_logging()\n        .with_container(\n            \"docker.io/restatedev/restate\".to_string(),\n            \"latest\".to_string(),\n        )\n        .build()\n        .start(endpoint)\n        .await\n        .unwrap();\n\n    let ingress_url = test_container.ingress_url();\n\n    // call container ingress url for /MyService/my_handler\n    let response = reqwest::Client::new()\n        .post(format!(\"{}/MyService/my_handler\", ingress_url))\n        .header(\"Accept\", \"application/json\")\n        .header(\"Content-Type\", \"*/*\")\n        .header(\"idempotency-key\", \"abc\")\n        .send()\n        .await\n        .unwrap();\n\n    assert_eq!(response.status(), StatusCode::OK);\n\n    info!(\n        \"/MyService/my_handler response: {:?}\",\n        response.text().await.unwrap()\n    );\n}\n```\n\n## Versions\n\nThe Rust SDK is currently in active development, and might break across releases.\n\nThe compatibility with Restate is described in the following table:\n\n| Restate Server\\sdk-rust | \u003c 0.4            | 0.4 - 0.5 | 0.6              | 0.7              |\n|-------------------------|------------------|-----------|------------------|------------------|\n| \u003c 1.3                   | ✅                | ❌         | ❌                | ❌                |\n| 1.3                     | ✅                | ✅         | ✅ \u003csup\u003e(1)\u003c/sup\u003e | ✅ \u003csup\u003e(2)\u003c/sup\u003e |\n| 1.4                     | ✅                | ✅         | ✅                | ✅ \u003csup\u003e(2)\u003c/sup\u003e |\n| 1.5                     | ⚠ \u003csup\u003e(3)\u003c/sup\u003e | ✅         | ✅                | ✅                |\n\n\u003csup\u003e(1)\u003c/sup\u003e **Note** `bind_with_options` works only from Restate 1.4 onward.\n\n\u003csup\u003e(2)\u003c/sup\u003e **Note** the new `retry_policy` options work only from Restate 1.5 onward. Check the in-code documentation for more details.\n\n\u003csup\u003e(3)\u003c/sup\u003e **Warning** SDK versions \u003c 0.4 are deprecated, and cannot be registered anymore. Check the [Restate 1.5 release notes](https://github.com/restatedev/restate/releases/tag/v1.5.0) for more info.\n\n## Contributing\n\nWe’re excited if you join the Restate community and start contributing!\nWhether it is feature requests, bug reports, ideas \u0026 feedback or PRs, we appreciate any and all contributions.\nWe know that your time is precious and, therefore, deeply value any effort to contribute!\n\n### Building the SDK locally\n\nPrerequisites:\n\n- [Rust](https://rustup.rs/)\n- [Just](https://github.com/casey/just)\n\nTo build and test the SDK:\n\n```shell\njust verify\n```\n\n### Releasing\n\nYou need the [Rust toolchain](https://rustup.rs/). To verify:\n\n```\njust verify\n```\n\nTo release we use [cargo-release](https://github.com/crate-ci/cargo-release):\n\n```\ncargo release \u003cVERSION\u003e --exclude test-services --workspace\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frestatedev%2Fsdk-rust","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frestatedev%2Fsdk-rust","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frestatedev%2Fsdk-rust/lists"}