Enum StreamMessage

Source
pub enum StreamMessage<'a> {
Show 14 variants Tweet(Box<Tweet<'a>>), Event(Box<Event<'a>>), Delete(Delete), ScrubGeo(ScrubGeo), Limit(Limit), StatusWithheld(StatusWithheld<'a>), UserWithheld(UserWithheld<'a>), Disconnect(Disconnect<'a>), Warning(Warning<'a>), Friends(Friends), DirectMessage(Box<DirectMessage<'a>>), Control(Control<'a>), ForUser(UserId, Box<StreamMessage<'a>>), Custom(JsonMap<String, JsonValue>),
}
Expand description

Represents a message from Twitter Streaming API.

§Reference

  1. Streaming message types — Twitter Developers

Variants§

§

Tweet(Box<Tweet<'a>>)

Tweet

§

Event(Box<Event<'a>>)

Notifications about non-Tweet events.

§

Delete(Delete)

Indicate that a given Tweet has been deleted.

§

ScrubGeo(ScrubGeo)

Indicate that geolocated data must be stripped from a range of Tweets.

§

Limit(Limit)

Indicate that a filtered stream has matched more Tweets than its current rate limit allows to be delivered, noticing a total count of the number of undelivered Tweets since the connection was opened.

§

StatusWithheld(StatusWithheld<'a>)

Indicate that a given tweet has had its content withheld.

§

UserWithheld(UserWithheld<'a>)

Indicate that a user has had their content withheld.

§

Disconnect(Disconnect<'a>)

This message is sent when a stream is disconnected, indicating why the stream was closed.

§

Warning(Warning<'a>)

Variout warning message

§

Friends(Friends)

List of the user’s friends. Only be sent upon establishing a User Stream connection.

§

DirectMessage(Box<DirectMessage<'a>>)

Direct message

§

Control(Control<'a>)

A [control URI][1] for Site Streams. [1]: https://dev.twitter.com/streaming/sitestreams/controlstreams

§

ForUser(UserId, Box<StreamMessage<'a>>)

An [envelope][1] for Site Stream. [1]: https://dev.twitter.com/streaming/overview/messages-types#envelopes_for_user

§

Custom(JsonMap<String, JsonValue>)

A message not known to this library.

Implementations§

Source§

impl<'a> StreamMessage<'a>

Source

pub fn from_str(json: &'a str) -> Result<Self>

Parse a JSON string returned from Twitter Streaming API.

Note that this method is not a member of the FromStr trait. It is because the method requires the lifetime information of the JSON string, while FromStr::from_str does not take a lifetime parameter.

use twitter_stream_message::message::{Delete, StreamMessage};

let parsed = StreamMessage::from_str(r#"{
    "delete":{
        "status":{
            "id":1234,
            "id_str":"1234",
            "user_id":3,
            "user_id_str":"3"
        }
    }
}"#).unwrap();
let expected = StreamMessage::Delete(Delete {
    id: 1234,
    user_id: 3,
});

assert_eq!(parsed, expected);

Trait Implementations§

Source§

impl<'a> Clone for StreamMessage<'a>

Source§

fn clone(&self) -> StreamMessage<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for StreamMessage<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de: 'a, 'a> Deserialize<'de> for StreamMessage<'a>

Source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<'a> PartialEq for StreamMessage<'a>

Source§

fn eq(&self, other: &StreamMessage<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> StructuralPartialEq for StreamMessage<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for StreamMessage<'a>

§

impl<'a> RefUnwindSafe for StreamMessage<'a>

§

impl<'a> Send for StreamMessage<'a>

§

impl<'a> Sync for StreamMessage<'a>

§

impl<'a> Unpin for StreamMessage<'a>

§

impl<'a> UnwindSafe for StreamMessage<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,