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
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>
impl<'a> StreamMessage<'a>
Sourcepub fn from_str(json: &'a str) -> Result<Self>
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>
impl<'a> Clone for StreamMessage<'a>
Source§fn clone(&self) -> StreamMessage<'a>
fn clone(&self) -> StreamMessage<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more