Builder

Struct Builder 

Source
pub struct Builder<'a, T = Token> { /* private fields */ }
Expand description

A builder for TwitterStream.

See the builder module documentation for details.

Implementations§

Source§

impl<'a, C, A> Builder<'a, Token<C, A>>
where C: AsRef<str>, A: AsRef<str>,

Source

pub fn new(token: Token<C, A>) -> Self

Creates a builder.

Source

pub fn listen(&self) -> FutureTwitterStream

Available on crate feature hyper only.

Start listening on the Streaming API endpoint, returning a Future which resolves to a Stream yielding JSON messages from the API.

§Panics

This will panic if the underlying HTTPS connector failed to initialize.

Source

pub fn listen_with_client<S, B>( &self, client: S, ) -> FutureTwitterStream<S::Future>
where S: HttpService<B>, B: From<Vec<u8>>,

Same as listen except that it uses client to make HTTP request to the endpoint.

client must be able to handle the https scheme.

§Panics

This will call <S as Service>::call without checking for <S as Service>::poll_ready and may cause a panic if client is not ready to send an HTTP request yet.

§Example
use tower::ServiceExt;

let stream = twitter_stream::Builder::new(token)
    .listen_with_client(client.ready_and().await?)
    .await
    .unwrap();
Source§

impl<'a, C, A> Builder<'a, Token<C, A>>

Source

pub fn endpoint( &mut self, endpoint: impl Into<Option<(RequestMethod, Uri)>>, ) -> &mut Self

Set the API endpoint URI to be connected.

This overrides the default behavior of automatically determining the endpoint to use.

Source

pub fn token(&mut self, token: Token<C, A>) -> &mut Self

Reset the token to be used to log into Twitter.

Source

pub 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.

Source

pub fn filter_level( &mut self, filter_level: impl Into<Option<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.

Source

pub fn language(&mut self, language: impl Into<Cow<'a, str>>) -> &mut Self

Set a comma-separated language identifiers to receive Tweets written in the specified languages only.

Setting an empty string will unset this parameter.

See the Twitter Developer Documentation for more information.

Source

pub fn follow(&mut self, follow: impl Into<Cow<'a, [u64]>>) -> &mut Self

Set a list of user IDs to receive Tweets from the specified users.

Setting an empty slice will unset this parameter.

See the Twitter Developer Documentation for more information.

Source

pub fn track(&mut self, track: impl Into<Cow<'a, str>>) -> &mut Self

A comma separated list of phrases to filter Tweets by.

Setting an empty string will unset this parameter.

See the Twitter Developer Documentation for more information.

Source

pub fn locations( &mut self, locations: impl Into<Cow<'a, [BoundingBox]>>, ) -> &mut Self

Set a list of bounding boxes to filter Tweets by.

Setting an empty slice will unset this parameter.

See BoundingBox and the Twitter Developer Documentation for more information.

Source

pub fn count(&mut self, count: impl Into<Option<i32>>) -> &mut Self

The count parameter. This parameter requires elevated access to use.

See the Twitter Developer Documentation for more information.

Trait Implementations§

Source§

impl<'a, T: Clone> Clone for Builder<'a, T>

Source§

fn clone(&self) -> Builder<'a, T>

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, T: Debug> Debug for Builder<'a, T>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, T = Token> !Freeze for Builder<'a, T>

§

impl<'a, T> RefUnwindSafe for Builder<'a, T>
where T: RefUnwindSafe,

§

impl<'a, T> Send for Builder<'a, T>
where T: Send,

§

impl<'a, T> Sync for Builder<'a, T>
where T: Sync,

§

impl<'a, T> Unpin for Builder<'a, T>
where T: Unpin,

§

impl<'a, T> UnwindSafe for Builder<'a, T>
where T: UnwindSafe,

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more