pub struct Client { /* private fields */ }
Expand description
Twitter API client that supports rate-limit-aware asynchronous streams.
Implementations§
Source§impl Client
impl Client
pub async fn new( user: TwitterUser, user_token: Token, app_token: Token, ) -> Result<Client>
Sourcepub async fn from_key_pairs(
consumer: KeyPair,
access: KeyPair,
) -> Result<Self, Error>
pub async fn from_key_pairs( consumer: KeyPair, access: KeyPair, ) -> Result<Self, Error>
Create a client from two key pairs.
Sourcepub async fn from_config_file<P: AsRef<Path>>(path: P) -> Result<Self, Error>
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.
pub async fn from_bearer_token(token: &str) -> Result<Self, Error>
Sourcepub fn blocked_ids(&self) -> LocalBoxStream<'_, EggModeResult<u64>>
pub fn blocked_ids(&self) -> LocalBoxStream<'_, EggModeResult<u64>>
Stream user IDs blocked by the authenticated user.
Sourcepub fn follower_ids<T: Into<UserID>>(
&self,
account: T,
token_type: TokenType,
) -> LocalBoxStream<'_, EggModeResult<u64>>
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.
Sourcepub fn self_follower_ids(&self) -> LocalBoxStream<'_, EggModeResult<u64>>
pub fn self_follower_ids(&self) -> LocalBoxStream<'_, EggModeResult<u64>>
Stream user IDs of followers of the authenticated user.
Sourcepub fn followed_ids<T: Into<UserID>>(
&self,
account: T,
token_type: TokenType,
) -> LocalBoxStream<'_, EggModeResult<u64>>
pub fn followed_ids<T: Into<UserID>>( &self, account: T, token_type: TokenType, ) -> LocalBoxStream<'_, EggModeResult<u64>>
Stream user IDs followed by the given account.
Sourcepub fn self_followed_ids(&self) -> LocalBoxStream<'_, EggModeResult<u64>>
pub fn self_followed_ids(&self) -> LocalBoxStream<'_, EggModeResult<u64>>
Stream user IDs followed by the authenticated user.
Sourcepub fn user_tweets<T: Into<UserID>>(
&self,
account: T,
with_replies: bool,
with_rts: bool,
token_type: TokenType,
) -> LocalBoxStream<'_, EggModeResult<Tweet>>
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.
Sourcepub fn user_timeline_stream<T: Into<UserID>>(
&self,
account: T,
wait: Duration,
token_type: TokenType,
) -> LocalBoxStream<'_, EggModeResult<Tweet>>
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.
Sourcepub async fn lookup_user<T: Into<UserID>>(
&self,
account: T,
token_type: TokenType,
) -> EggModeResult<TwitterUser>
pub async fn lookup_user<T: Into<UserID>>( &self, account: T, token_type: TokenType, ) -> EggModeResult<TwitterUser>
Look up a single user.
Sourcepub async fn lookup_user_or_status<T: Into<UserID>>(
&self,
account: T,
token_type: TokenType,
) -> EggModeResult<Result<TwitterUser, FormerUserStatus>>
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).
Sourcepub fn lookup_users<T: Into<UserID> + Unpin + Send, I: IntoIterator<Item = T>>(
&self,
accounts: I,
token_type: TokenType,
) -> LocalBoxStream<'_, EggModeResult<TwitterUser>>
pub fn lookup_users<T: Into<UserID> + Unpin + Send, I: IntoIterator<Item = T>>( &self, accounts: I, token_type: TokenType, ) -> LocalBoxStream<'_, EggModeResult<TwitterUser>>
Stream users.
Sourcepub 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>>>
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).
Sourcepub fn lookup_users_json<T: Into<UserID> + Unpin + Send, I: IntoIterator<Item = T>>(
&self,
accounts: I,
token_type: TokenType,
) -> LocalBoxStream<'_, EggModeResult<Value>>
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.
Sourcepub 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)>>>
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).
Sourcepub 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)>>>
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.
Sourcepub async fn lookup_reply_parent(
&self,
status_id: u64,
token_type: TokenType,
) -> EggModeResult<Option<(String, u64)>>
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.
Sourcepub fn lookup_tweets<I: IntoIterator<Item = u64>>(
&self,
status_ids: I,
token_type: TokenType,
) -> LocalBoxStream<'_, EggModeResult<(u64, Option<Tweet>)>>
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.
Sourcepub async fn block_user<T: Into<UserID>>(
&self,
account: T,
) -> EggModeResult<TwitterUser>
pub async fn block_user<T: Into<UserID>>( &self, account: T, ) -> EggModeResult<TwitterUser>
Block the specified account for the authenticated user.