{"id":20770452,"url":"https://github.com/ably/ably-rust","last_synced_at":"2025-04-30T13:50:14.782Z","repository":{"id":39879291,"uuid":"458147021","full_name":"ably/ably-rust","owner":"ably","description":"Rust SDK for Ably realtime messaging service. Developer Preview.","archived":false,"fork":false,"pushed_at":"2023-02-27T22:31:51.000Z","size":336,"stargazers_count":12,"open_issues_count":12,"forks_count":1,"subscribers_count":23,"default_branch":"main","last_synced_at":"2025-03-30T16:39:15.520Z","etag":null,"topics":["client-library","rust","rust-lang","rust-library","sdk"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ably.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}},"created_at":"2022-02-11T10:48:36.000Z","updated_at":"2024-07-12T22:01:56.000Z","dependencies_parsed_at":"2023-01-24T07:45:37.416Z","dependency_job_id":null,"html_url":"https://github.com/ably/ably-rust","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ably%2Fably-rust","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ably%2Fably-rust/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ably%2Fably-rust/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ably%2Fably-rust/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ably","download_url":"https://codeload.github.com/ably/ably-rust/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251714740,"owners_count":21631779,"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":["client-library","rust","rust-lang","rust-library","sdk"],"created_at":"2024-11-17T12:09:34.902Z","updated_at":"2025-04-30T13:50:14.755Z","avatar_url":"https://github.com/ably.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [Ably](https://www.ably.com)\n\n[![Check](https://github.com/ably/ably-rust/actions/workflows/check.yml/badge.svg)](https://github.com/ably/ably-rust/actions/workflows/check.yml)\n[![Features](https://github.com/ably/ably-rust/actions/workflows/features.yml/badge.svg)](https://github.com/ably/ably-rust/actions/workflows/features.yml)\n\n_[Ably](https://ably.com) is the platform that powers synchronized digital experiences in realtime. Whether attending an event in a virtual venue, receiving realtime financial information, or monitoring live car performance data – consumers simply expect realtime digital experiences as standard. Ably provides a suite of APIs to build, extend, and deliver powerful digital experiences in realtime for more than 250 million devices across 80 countries each month. Organizations like Bloomberg, HubSpot, Verizon, and Hopin depend on Ably’s platform to offload the growing complexity of business-critical realtime data synchronization at global scale. For more information, see the [Ably documentation](https://ably.com/documentation)._\n\nThis is a Rust client library for the Ably REST API. It does not currently include any realtime features.\n\n**NOTE: This SDK is a developer preview and not considered production ready.**\n\n## Installation\n\nAdd the `ably` and `tokio` crates to your `Cargo.toml`:\n\n```\n[dependencies]\nably = \"0.2.0\"\ntokio = { version = \"1\", features = [\"full\"] }\n```\n\n## Using the REST API\n\n### Initialize A Client\n\nInitialize a client with a method to authenticate with Ably.\n\n- With an API Key:\n\n```rust\nlet client = ably::Rest::from(\"xVLyHw.SmDuMg:************\");\n```\n\n- With an auth URL:\n\n```rust\nlet auth_url = \"https://example.com/auth\".parse()?;\n\nlet client = ably::ClientOptions::new().auth_url(auth_url).client()?;\n```\n\n### Publish A Message\n\nGiven:\n\n```rust\nlet channel = client.channels.get(\"test\");\n```\n\n- Publish a string:\n\n```rust\nlet result = channel.publish().string(\"a string\").send().await;\n```\n\n- Publish a JSON object:\n\n```rust\n#[derive(Serialize)]\nstruct Point {\n    x: i32,\n    y: i32,\n}\nlet point = Point { x: 3, y: 4 };\nlet result = channel.publish().json(point).send().await;\n```\n\n- Publish binary data:\n\n```rust\nlet data = vec![0x01, 0x02, 0x03, 0x04];\nlet result = channel.publish().binary(data).send().await;\n```\n\n### Retrieve History\n\n```rust\nlet mut pages = channel.history().pages();\nwhile let Some(Ok(page)) = pages.next().await {\n    for msg in page.items().await? {\n        println!(\"message data = {:?}\", msg.data);\n    }\n}\n```\n\n### Retrieve Presence\n\n```rust\nlet mut pages = channel.presence.get().pages();\nwhile let Some(Ok(page)) = pages.next().await {\n    for msg in page.items().await? {\n        println!(\"presence data = {:?}\", msg.data);\n    }\n}\n```\n\n### Retrieve Presence History\n\n```rust\nlet mut pages = channel.presence.history().pages();\nwhile let Some(Ok(page)) = pages.next().await {\n    for msg in page.items().await? {\n        println!(\"presence data = {:?}\", msg.data);\n    }\n}\n```\n\n### Encrypted Message Data\n\nWhen a 128 bit or 256 bit key is provided to the library, the data attributes of all messages are encrypted and decrypted automatically using that key. The secret key is never transmitted to Ably. See https://www.ably.com/documentation/realtime/encryption\n\n```rust\n// Initialize a channel with cipher parameters so that published messages\n// get encrypted.\nlet cipher_key = ably::crypto::generate_random_key::\u003cably::crypto::Key256\u003e();\nlet params = ably::rest::CipherParams::from(cipher_key);\nlet channel = client.channels.name(\"rust-example\").cipher(params).get();\n\nchannel\n    .publish()\n    .name(\"name is not encrypted\")\n    .string(\"sensitive data is encrypted\")\n    .send()\n    .await;\n```\n\n\n### Request A Token\n\n```rust\nlet result = client\n    .auth\n    .request_token()\n    .client_id(\"test@example.com\")\n    .capability(r#\"{\"example\":[\"subscribe\"]}\"#)\n    .send()\n    .await;\n```\n\n### Retrieve Application Statistics\n\n```rust\nlet mut pages = client.stats().pages();\nwhile let Some(Ok(page)) = pages.next().await {\n    for stats in page.items().await? {\n        println!(\"stats = {:?}\", stats);\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fably%2Fably-rust","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fably%2Fably-rust","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fably%2Fably-rust/lists"}