Struct twitter_stream::TwitterStreamBuilder
[−]
[src]
pub struct TwitterStreamBuilder<'a, CH: 'a> { /* fields omitted */ }
A builder for TwitterStream
.
Example
extern crate futures; extern crate tokio_core; extern crate twitter_stream; use futures::{Future, Stream}; use tokio_core::reactor::Core; use twitter_stream::{Token, TwitterStreamBuilder}; let token = Token::new("consumer_key", "consumer_secret", "access_key", "access_secret"); let mut core = Core::new().unwrap(); let handle = core.handle(); let future = TwitterStreamBuilder::user(&token) .handle(&handle) .timeout(None) .replies(true) .listen() // You cannot call `listen` method before you call `client` or `handle` method. .flatten_stream() .for_each(|json| { println!("{}", json); Ok(()) }); core.run(future).unwrap();
Methods
impl<'a> TwitterStreamBuilder<'a, ()>
[src]
fn filter(token: &'a Token<'a>) -> TwitterStreamBuilder<'a, ()>
Create a builder for POST statuses/filter
endpoint.
See the Twitter Developer Documentation for more information.
fn sample(token: &'a Token<'a>) -> TwitterStreamBuilder<'a, ()>
Create a builder for GET statuses/sample
endpoint.
See the Twitter Developer Documentation for more information.
fn user(token: &'a Token<'a>) -> TwitterStreamBuilder<'a, ()>
Create a builder for GET user
endpoint (a.k.a. User Stream).
See the Twitter Developer Documentation for more information.
fn custom(
method: RequestMethod,
end_point: &'a Url,
token: &'a Token<'a>
) -> TwitterStreamBuilder<'a, ()>
method: RequestMethod,
end_point: &'a Url,
token: &'a Token<'a>
) -> TwitterStreamBuilder<'a, ()>
Constructs a builder for a Stream at a custom end point.
impl<'a, CH> TwitterStreamBuilder<'a, CH>
[src]
fn client<C, B>(
self,
client: &'a Client<C, B>
) -> TwitterStreamBuilder<'a, Client<C, B>> where
C: Connect,
B: From<Vec<u8>> + Stream<Error = HyperError> + 'static,
B::Item: AsRef<[u8]>,
self,
client: &'a Client<C, B>
) -> TwitterStreamBuilder<'a, Client<C, B>> where
C: Connect,
B: From<Vec<u8>> + Stream<Error = HyperError> + 'static,
B::Item: AsRef<[u8]>,
Set a hyper::Client
to be used for connecting to the server.
The Client
should be able to handle the https
scheme.
This method overrides the effect of handle
method.
fn handle(self, handle: &'a Handle) -> TwitterStreamBuilder<'a, Handle>
Set a tokio_core::reactor::Handle
to be used for connecting to the server.
This method overrides the effect of client
method.
fn method(&mut self, method: RequestMethod) -> &mut Self
Reset the HTTP request method to be used when connecting to the server.
fn end_point(&mut self, end_point: &'a Url) -> &mut Self
Reset the API endpoint URL to be connected.
fn token(&mut self, token: &'a Token<'a>) -> &mut Self
Reset the token to be used to log into Twitter.
fn user_agent<T>(&mut self, user_agent: Option<T>) -> &mut Self where
T: Into<Cow<'static, str>>,
T: Into<Cow<'static, str>>,
Set a user agent string to be sent when connectiong to the Stream.
fn timeout(&mut self, timeout: Option<Duration>) -> &mut Self
Set a timeout for the stream. None
means infinity.
fn stall_warnings(&mut self, stall_warnings: bool) -> &mut Self
Set whether to receive messages when in danger of being disconnected.
See the Twitter Developer Documentation for more information.
fn filter_level(&mut self, filter_level: FilterLevel) -> &mut Self
Set the minimum filter_level
Tweet attribute to receive. The default is FilterLevel::None
.
See the Twitter Developer Documentation for more information.
fn language(&mut self, language: Option<&'a str>) -> &mut Self
Set a comma-separated language identifiers to receive Tweets written in the specified languages only.
See the Twitter Developer Documentation for more information.
fn follow(&mut self, follow: Option<&'a [u64]>) -> &mut Self
Set a list of user IDs to receive Tweets only from the specified users.
See the [Twitter Developer Documentation][1] for more information. [1] https://dev.twitter.com/streaming/overview/request-parameters#follow
fn track(&mut self, track: Option<&'a str>) -> &mut Self
A comma separated list of phrases to filter Tweets by.
See the Twitter Developer Documentation for more information.
fn locations(
&mut self,
locations: Option<&'a [((f64, f64), (f64, f64))]>
) -> &mut Self
&mut self,
locations: Option<&'a [((f64, f64), (f64, f64))]>
) -> &mut Self
Set a list of bounding boxes to filter Tweets by, specified by a pair of coordinates in the form of ((longitude, latitude), (longitude, latitude)) tuple.
See the Twitter Developer Documentation for more information.
fn count(&mut self, count: Option<i32>) -> &mut Self
The count
parameter. This parameter requires elevated access to use.
See the Twitter Developer Documentation for more information.
fn with(&mut self, with: Option<With>) -> &mut Self
Set types of messages delivered to User and Site Streams clients.
fn replies(&mut self, replies: bool) -> &mut Self
Set whether to receive all @replies.
See the Twitter Developer Documentation for more information.
impl<'a, C, B> TwitterStreamBuilder<'a, Client<C, B>> where
C: Connect,
B: From<Vec<u8>> + Stream<Error = HyperError> + 'static,
B::Item: AsRef<[u8]>,
[src]
C: Connect,
B: From<Vec<u8>> + Stream<Error = HyperError> + 'static,
B::Item: AsRef<[u8]>,
fn listen(&self) -> FutureTwitterStream
Attempt to start listening on a Stream and returns a Stream
object which yields parsed messages from the API.
You need to call client
method before trying to call this method.
impl<'a> TwitterStreamBuilder<'a, Handle>
[src]
fn listen(&self) -> FutureTwitterStream
Attempt to start listening on a Stream and returns a Stream
object which yields JSON messages from the API.
You need to call handle
method before trying to call this method.
Trait Implementations
impl<'a, CH: Clone + 'a> Clone for TwitterStreamBuilder<'a, CH>
[src]
fn clone(&self) -> TwitterStreamBuilder<'a, CH>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more