Enum twitch_api2::pubsub::TopicSubscribe[][src]

pub enum TopicSubscribe {
    Listen {
        nonce: Option<String>,
        topics: Vec<String>,
        auth_token: String,
    },
    Unlisten {
        nonce: Option<String>,
        topics: Vec<String>,
        auth_token: String,
    },
}
This is supported on crate feature pubsub only.

Command that can be serialized to be sent to twitchs PubSub server to subscribe or unsubscribe to a Topic

Variants

Listen

Subscribe/Listen

Fields of Listen

nonce: Option<String>

Random string to identify the response associated with this request.

topics: Vec<String>

List of topics to listen on.

auth_token: String

OAuth token required to listen on some topics.

Unlisten

Unsubscribe/Unlisten

Fields of Unlisten

nonce: Option<String>

Random string to identify the response associated with this request.

topics: Vec<String>

List of topics to listen on.

auth_token: String

OAuth token required to listen on some topics.

Implementations

impl TopicSubscribe[src]

pub fn to_command(&self) -> Result<String, Error>[src]

Convert this TopicSubscribe to a string which you can send with your client

pub fn listen<'a, T: Topic, O: Into<Option<String>>>(
    topics: &'a [T],
    auth_token: String,
    nonce: O
) -> TopicSubscribe where
    &'a T: Into<String>, 
[src]

Create a listen command.

Example

Create a listen message for moderator actions

// We want to subscribe to moderator actions on channel with id 1234
// as if we were a user with id 4321 that is moderator on the channel.
let topic = pubsub::moderation::ChatModeratorActions {
    user_id: 4321,
    channel_id: 1234,
};

// Create the topic command to send to twitch
let command = pubsub::TopicSubscribe::listen(
    &[topic],
    "authtoken".to_string(),
    "super se3re7 random string".to_string(),
)
.to_command().expect("serializing failed");
// Send the message with your favorite websocket client
send_command(command).unwrap();
// To parse the websocket messages, use pubsub::Response::parse

pub fn unlisten<'a, T: Topic, O: Into<Option<String>>>(
    topics: &'a [T],
    auth_token: String,
    nonce: O
) -> TopicSubscribe where
    &'a T: Into<String>, 
[src]

Create a unlisten command.

Trait Implementations

impl Serialize for TopicSubscribe[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

impl<T> WithSubscriber for T[src]