pub struct XApiHttpClient { /* private fields */ }Expand description
HTTP client for the X API v2.
Uses reqwest with Bearer token authentication. The access token
is stored behind an Arc<RwLock> so the token manager can
update it transparently after a refresh.
Implementations§
Source§impl XApiHttpClient
impl XApiHttpClient
Sourcepub fn new(access_token: String) -> Self
pub fn new(access_token: String) -> Self
Create a new X API HTTP client with the given access token.
Sourcepub fn with_base_url(access_token: String, base_url: String) -> Self
pub fn with_base_url(access_token: String, base_url: String) -> Self
Create a new client with a custom base URL (for testing with wiremock).
Sourcepub fn access_token_lock(&self) -> Arc<RwLock<String>>
pub fn access_token_lock(&self) -> Arc<RwLock<String>>
Get a shared reference to the access token lock for token manager integration.
Sourcepub async fn set_access_token(&self, token: String)
pub async fn set_access_token(&self, token: String)
Update the access token (used by token manager after refresh).
Trait Implementations§
Source§impl XApiClient for XApiHttpClient
impl XApiClient for XApiHttpClient
Source§fn search_tweets<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
query: &'life1 str,
max_results: u32,
since_id: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<SearchResponse, XApiError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn search_tweets<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
query: &'life1 str,
max_results: u32,
since_id: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<SearchResponse, XApiError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Search recent tweets matching the given query. Read more
Source§fn get_mentions<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
user_id: &'life1 str,
since_id: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<MentionResponse, XApiError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn get_mentions<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
user_id: &'life1 str,
since_id: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<MentionResponse, XApiError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Get mentions for the authenticated user. Read more
Source§fn post_tweet<'life0, 'life1, 'async_trait>(
&'life0 self,
text: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<PostedTweet, XApiError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn post_tweet<'life0, 'life1, 'async_trait>(
&'life0 self,
text: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<PostedTweet, XApiError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Post a new tweet.
Source§fn reply_to_tweet<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
text: &'life1 str,
in_reply_to_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<PostedTweet, XApiError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn reply_to_tweet<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
text: &'life1 str,
in_reply_to_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<PostedTweet, XApiError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Reply to an existing tweet.
Source§fn get_tweet<'life0, 'life1, 'async_trait>(
&'life0 self,
tweet_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Tweet, XApiError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_tweet<'life0, 'life1, 'async_trait>(
&'life0 self,
tweet_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Tweet, XApiError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get a single tweet by ID.
Source§fn get_me<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<User, XApiError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_me<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<User, XApiError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get the authenticated user’s profile.
Source§fn get_user_tweets<'life0, 'life1, 'async_trait>(
&'life0 self,
user_id: &'life1 str,
max_results: u32,
) -> Pin<Box<dyn Future<Output = Result<SearchResponse, XApiError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_user_tweets<'life0, 'life1, 'async_trait>(
&'life0 self,
user_id: &'life1 str,
max_results: u32,
) -> Pin<Box<dyn Future<Output = Result<SearchResponse, XApiError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get recent tweets from a specific user.
Source§fn follow_user<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
source_user_id: &'life1 str,
target_user_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), XApiError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn follow_user<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
source_user_id: &'life1 str,
target_user_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), XApiError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Follow a user by their user ID.
Auto Trait Implementations§
impl Freeze for XApiHttpClient
impl !RefUnwindSafe for XApiHttpClient
impl Send for XApiHttpClient
impl Sync for XApiHttpClient
impl Unpin for XApiHttpClient
impl UnsafeUnpin for XApiHttpClient
impl !UnwindSafe for XApiHttpClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more