Struct egg_mode::stream::StreamBuilder
source · pub struct StreamBuilder { /* private fields */ }
Expand description
Represents a TwitterStream
before it is started. Use the various methods to build
up the filters on your stream.
Bear in mind that the track
, follow
and locations
filters are OR
ed rather than AND
ed
together. E.g. if you specify a user id to follow and a phrase to track, you will receive
all tweets that match (user id OR phrase), NOT (user id AND phrase).
For more details see the official docs
Note: The user must specify at least one track
, follow
or locations
filter or else
the stream will fail at point of connection.
Implementations§
source§impl StreamBuilder
impl StreamBuilder
sourcepub fn follow(self, to_follow: &[u64]) -> Self
pub fn follow(self, to_follow: &[u64]) -> Self
Filter stream to only return Tweets relating to given user IDs.
Example
use egg_mode::stream::filter;
let stream = filter()
// View tweets related to BBC news, the Guardian and the New York Times
.follow(&[612473, 87818409, 807095])
.start(&token);
sourcepub fn track<I: IntoIterator<Item = S>, S: AsRef<str>>(self, to_track: I) -> Self
pub fn track<I: IntoIterator<Item = S>, S: AsRef<str>>(self, to_track: I) -> Self
Filter stream to only return Tweets containing given phrases.
A phrase may be one or more terms separated by spaces, and a phrase will match if all of the terms in the phrase are present in the Tweet, regardless of order and ignoring case.
sourcepub fn language<I: IntoIterator<Item = S>, S: AsRef<str>>(
self,
languages: I
) -> Self
pub fn language<I: IntoIterator<Item = S>, S: AsRef<str>>(
self,
languages: I
) -> Self
Filter stream to only return Tweets that have been detected as being written in the specified languages.
Languages are specified as a list of BCP 47 language identifiers corresponding to any of the languages listed on Twitter’s advanced search page.
Note This library does not validate the language codes.
sourcepub fn locations(self, locations: &[BoundingBox]) -> Self
pub fn locations(self, locations: &[BoundingBox]) -> Self
A list of bounding boxes by which to filter Tweets
Example
use egg_mode::stream::{filter, BoundingBox};
let stream = filter()
// Only show tweets sent from New York
.locations(&[BoundingBox::new((-74.0,40.0),(-73.0,41.0))])
.start(&token);
sourcepub fn filter_level(self, filter_level: FilterLevel) -> StreamBuilder
pub fn filter_level(self, filter_level: FilterLevel) -> StreamBuilder
Applies the given FilterLevel
to the stream. Tweets with a filter_level
below the given
value will not be shown in the stream.
When displaying a stream of Tweets to end users (dashboards or live feeds at a presentation or conference, for example) it is suggested that you set this value to medium.
sourcepub fn start(self, token: &Token) -> TwitterStream
pub fn start(self, token: &Token) -> TwitterStream
Finalizes the stream parameters and returns the resulting TwitterStream
.