[−][src]Crate pusher
Pusher-HTTP-Rust
The Rust library for interacting with the Pusher HTTP API.
This package lets you trigger events to your client and query the state of your Pusher channels. When used with a server, you can validate Pusher webhooks and authenticate private- or presence-channels.
In order to use this library, you need to have a free account on http://pusher.com. After registering, you will need the application credentials for your app.
Getting Started
Firstly, add pusher
to your Cargo.toml
.
To trigger an event:
extern crate pusher; // imports the `pusher` module use pusher::PusherBuilder; // brings the PusherBuilder struct into scope fn main(){ // initializes a Pusher object with your app credentials let pusher = PusherBuilder::new("APP_ID", "KEY", "SECRET").finalize(); // triggers an event called "my_event" on a channel called "test_channel", with the payload "hello world!" pusher.trigger("test_channel", "my_event", "hello world!"); }
Structs
Channel | This represents the data received upon querying the state of a Pusher channel. |
ChannelList | A list of channels returned by the API. |
ChannelUser | A particular user who occupies a presence channel. |
ChannelUserList | The list of users subscribed to a presence channel, as returned by the Pusher API. |
Member | When authenticating presence-channels, this represents a particular member of the channel. This object becomes associated with that user's subscription. |
Pusher | A client to interact with Pusher's HTTP API to trigger, query application state, authenticate private- or presence-channels, and validate webhooks. |
PusherBuilder | An ephemeral object upon which to pass configuration options to when initializing a Pusher instance. |
TriggeredEvents | Any event_ids returned by the HTTP API, if connected to certain clusters. |
Webhook | This is returned upon validating that a webhook is indeed from Pusher, carrying all the data received by that POST request. |
Type Definitions
QueryParameters | When querying the state of Pusher channels, you can pass this in to specify options. |