Struct Client

Source
pub struct Client { /* private fields */ }
Expand description

Twitter API client that supports rate-limit-aware asynchronous streams.

Implementations§

Source§

impl Client

Source

pub async fn new( user: TwitterUser, user_token: Token, app_token: Token, ) -> Result<Client>

Source

pub async fn from_key_pairs( consumer: KeyPair, access: KeyPair, ) -> Result<Self, Error>

Create a client from two key pairs.

Source

pub async fn from_config_file<P: AsRef<Path>>(path: P) -> Result<Self, Error>

Create a client from two key pairs read from a TOML config file.

Source

pub async fn from_bearer_token(token: &str) -> Result<Self, Error>

Source

pub fn user_id(&self) -> u64

Twitter ID of the authenticated user.

Source

pub fn blocked_ids(&self) -> LocalBoxStream<'_, EggModeResult<u64>>

Stream user IDs blocked by the authenticated user.

Source

pub fn follower_ids<T: Into<UserID>>( &self, account: T, token_type: TokenType, ) -> LocalBoxStream<'_, EggModeResult<u64>>

Stream user IDs of followers for the given account.

Source

pub fn self_follower_ids(&self) -> LocalBoxStream<'_, EggModeResult<u64>>

Stream user IDs of followers of the authenticated user.

Source

pub fn followed_ids<T: Into<UserID>>( &self, account: T, token_type: TokenType, ) -> LocalBoxStream<'_, EggModeResult<u64>>

Stream user IDs followed by the given account.

Source

pub fn self_followed_ids(&self) -> LocalBoxStream<'_, EggModeResult<u64>>

Stream user IDs followed by the authenticated user.

Source

pub fn user_tweets<T: Into<UserID>>( &self, account: T, with_replies: bool, with_rts: bool, token_type: TokenType, ) -> LocalBoxStream<'_, EggModeResult<Tweet>>

Stream tweets by the given user.

Source

pub fn user_timeline_stream<T: Into<UserID>>( &self, account: T, wait: Duration, token_type: TokenType, ) -> LocalBoxStream<'_, EggModeResult<Tweet>>

Stream the given user’s timeline.

Source

pub async fn lookup_user<T: Into<UserID>>( &self, account: T, token_type: TokenType, ) -> EggModeResult<TwitterUser>

Look up a single user.

Source

pub async fn lookup_user_or_status<T: Into<UserID>>( &self, account: T, token_type: TokenType, ) -> EggModeResult<Result<TwitterUser, FormerUserStatus>>

Look up a single user (or their status if they are unavailable).

Source

pub fn lookup_users<T: Into<UserID> + Unpin + Send, I: IntoIterator<Item = T>>( &self, accounts: I, token_type: TokenType, ) -> LocalBoxStream<'_, EggModeResult<TwitterUser>>

Stream users.

Source

pub fn lookup_users_json_or_missing<T: Into<UserID> + Unpin + Send, I: IntoIterator<Item = T>>( &self, accounts: I, token_type: TokenType, ) -> LocalBoxStream<'_, EggModeResult<Result<Value, UserID>>>

Stream user JSON objects (or their IDs if they are unavailable).

Source

pub fn lookup_users_json<T: Into<UserID> + Unpin + Send, I: IntoIterator<Item = T>>( &self, accounts: I, token_type: TokenType, ) -> LocalBoxStream<'_, EggModeResult<Value>>

Stream user JSON objects.

Source

pub fn lookup_users_json_or_status<T: Into<UserID> + Unpin + Send, I: IntoIterator<Item = T>>( &self, accounts: I, token_type: TokenType, ) -> LocalBoxStream<'_, EggModeResult<Result<Value, (UserID, FormerUserStatus)>>>

Stream user JSON objects (or their statuses if they are unavailable).

Source

pub fn lookup_users_or_status<T: Into<UserID> + Unpin + Send, I: IntoIterator<Item = T>>( &self, accounts: I, token_type: TokenType, ) -> LocalBoxStream<'_, EggModeResult<Result<TwitterUser, (UserID, FormerUserStatus)>>>

Stream users (or their statuses if they are unavailable).

Note that lookup_users_json_or_status will generally be more efficient.

Source

pub async fn lookup_reply_parent( &self, status_id: u64, token_type: TokenType, ) -> EggModeResult<Option<(String, u64)>>

Attempt to find a tweet that the tweet with the given status ID is a reply to.

Source

pub fn lookup_tweets<I: IntoIterator<Item = u64>>( &self, status_ids: I, token_type: TokenType, ) -> LocalBoxStream<'_, EggModeResult<(u64, Option<Tweet>)>>

Stream tweets for the given status IDs.

Source

pub async fn block_user<T: Into<UserID>>( &self, account: T, ) -> EggModeResult<TwitterUser>

Block the specified account for the authenticated user.

Auto Trait Implementations§

§

impl Freeze for Client

§

impl RefUnwindSafe for Client

§

impl Send for Client

§

impl Sync for Client

§

impl Unpin for Client

§

impl UnwindSafe for Client

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> 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, 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
Source§

impl<T> ErasedDestructor for T
where T: 'static,