Struct ably::rest::Rest

source ·
pub struct Rest { /* private fields */ }

Implementations

Start building a GET request to /stats.

Returns a stats::RequestBuilder which is used to set parameters before sending the stats request.

Example
use ably::stats::Stats;

let client = ably::Rest::from("<api_key>");

let res = client
    .stats()
    .start("2021-09-09:15:00")
    .end("2021-09-09:15:05")
    .send()
    .await?;

let stats = res.items().await?;

Sends a GET request to /time and returns the server time in UTC.

Example
let client = ably::Rest::from("<api_key>");

let time = client.time().await?;

Start building a HTTP request to the Ably REST API.

Returns a RequestBuilder which can be used to set query params, headers and the request body before sending the request.

Example
use ably::http::{HeaderMap,Method};

let client = ably::Rest::from("<api_key>");

let mut headers = HeaderMap::new();
headers.insert("Foo", "Bar".parse().unwrap());

let response = client
    .request(Method::POST, "/some/custom/path")
    .params(&[("key1", "val1"), ("key2", "val2")])
    .body(r#"{"json":"body"}"#)
    .headers(headers)
    .send()
    .await?;
Errors

Returns an error if sending the request fails or if the resulting response is unsuccessful (i.e. the status code is not in the 200-299 range).

Start building a paginated HTTP request to the Ably REST API.

Returns a PaginatedRequestBuilder which can be used to set query params before sending the request.

Example
use futures::TryStreamExt;
use ably::http::Method;

let client = ably::Rest::from("<api_key>");

let mut pages = client
    .paginated_request::<String>(Method::GET, "/time")
    .forwards()
    .limit(1)
    .pages();

let page = pages.try_next().await?.expect("Expected a page");

let items = page.items().await?;

assert_eq!(items.len(), 1);
Errors

Returns an error if sending the request fails or if the resulting response is unsuccessful (i.e. the status code is not in the 200-299 range).

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

Returns a Rest client initialised with an API key or token contained in the given string.

Example
// Initialise a Rest client with an API key.
let client = ably::Rest::from("<api_key>");
// Initialise a Rest client with a token.
let client = ably::Rest::from("<token>");

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more