Reliably
A fully-featured real-time Rust client for Ably.
Ably is the platform that powers synchronized digital experiences in realtime. For more information, see the Ably documentation.
This is a community-maintained fork of the original ably-rust SDK.
Installation
Add the reliably and tokio crates to your Cargo.toml:
[dependencies]
reliably = "0.2.0"
tokio = { version = "1", features = ["full"] }
[dependencies] ably = "0.2.0" tokio = { version = "1", features = ["full"] }
## Using the REST API
### Initialize A Client
Initialize a client with a method to authenticate with Ably.
- With an API Key:
```rust
let client = reliably::Rest::from("xVLyHw.SmDuMg:************");
- With an auth URL:
let auth_url = "https://example.com/auth".parse?;
let client = new.auth_url.client?;
Publish A Message
Given:
let channel = client.channels.get;
- Publish a string:
let result = channel.publish.string.send.await;
- Publish a JSON object:
let point = Point ;
let result = channel.publish.json.send.await;
- Publish binary data:
let data = vec!;
let result = channel.publish.binary.send.await;
Retrieve History
let mut pages = channel.history.pages;
while let Some = pages.next.await
Retrieve Presence
let mut pages = channel.presence.get.pages;
while let Some = pages.next.await
Retrieve Presence History
let mut pages = channel.presence.history.pages;
while let Some = pages.next.await
Encrypted Message Data
When 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
// Initialize a channel with cipher parameters so that published messages
// get encrypted.
let cipher_key = ;
let params = from;
let channel = client.channels.name.cipher.get;
channel
.publish
.name
.string
.send
.await;
Request A Token
let result = client
.auth
.request_token
.client_id
.capability
.send
.await;
Retrieve Application Statistics
let mut pages = client.stats.pages;
while let Some = pages.next.await