pub struct AccountsHandler<'a> { /* private fields */ }Expand description
Handler for account-related API endpoints.
Implementations§
Source§impl<'a> AccountsHandler<'a>
impl<'a> AccountsHandler<'a>
Sourcepub fn new(client: &'a MastodonClient) -> Self
pub fn new(client: &'a MastodonClient) -> Self
Creates a new AccountsHandler for the given client.
Parameters:
client: The client to use for making requests.
Returns:
AccountsHandler: The created accounts handler.
Sourcepub async fn verify_credentials(&self) -> Result<Account>
pub async fn verify_credentials(&self) -> Result<Account>
Verifies the authenticated user’s credentials and returns their account info.
Returns:
Result<Account>: The verified account.
Corresponds to GET /api/v1/accounts/verify_credentials.
Sourcepub async fn get(&self, id: &str) -> Result<Account>
pub async fn get(&self, id: &str) -> Result<Account>
Fetches an account by its ID.
Parameters:
id: The ID of the account to fetch.
Returns:
Result<Account>: The fetched account.
Corresponds to GET /api/v1/accounts/:id.
Sourcepub async fn follow(&self, id: &str) -> Result<Relationship>
pub async fn follow(&self, id: &str) -> Result<Relationship>
Follows the given account.
Parameters:
id: The ID of the account to follow.
Returns:
Result<crate::models::Relationship>: The followed relationship.
Corresponds to POST /api/v1/accounts/:id/follow.
Sourcepub async fn unfollow(&self, id: &str) -> Result<Relationship>
pub async fn unfollow(&self, id: &str) -> Result<Relationship>
Unfollows the given account.
Parameters:
id: The ID of the account to unfollow.
Returns:
Result<crate::models::Relationship>: The unfollowed relationship.
Corresponds to POST /api/v1/accounts/:id/unfollow.
Sourcepub async fn block(&self, id: &str) -> Result<Relationship>
pub async fn block(&self, id: &str) -> Result<Relationship>
Blocks the given account.
Parameters:
id: The ID of the account to block.
Returns:
Result<crate::models::Relationship>: The blocked relationship.
Corresponds to POST /api/v1/accounts/:id/block.
Sourcepub async fn mute(&self, id: &str) -> Result<Relationship>
pub async fn mute(&self, id: &str) -> Result<Relationship>
Mutes the given account.
Parameters:
id: The ID of the account to mute.
Returns:
Result<crate::models::Relationship>: The muted relationship.
Corresponds to POST /api/v1/accounts/:id/mute.
Sourcepub async fn pin(&self, id: &str) -> Result<Relationship>
pub async fn pin(&self, id: &str) -> Result<Relationship>
Pins the given account to the authenticated user’s profile.
Parameters:
id: The ID of the account to pin.
Returns:
Result<crate::models::Relationship>: The updated relationship.
Corresponds to POST /api/v1/accounts/:id/pin.
Sourcepub async fn unpin(&self, id: &str) -> Result<Relationship>
pub async fn unpin(&self, id: &str) -> Result<Relationship>
Unpins the given account from the profile.
Parameters:
id: The ID of the account to unpin.
Returns:
Result<crate::models::Relationship>: The updated relationship.
Corresponds to POST /api/v1/accounts/:id/unpin.
Sourcepub async fn search(
&self,
query: &str,
limit: Option<u32>,
) -> Result<Vec<Account>>
pub async fn search( &self, query: &str, limit: Option<u32>, ) -> Result<Vec<Account>>
Searches for accounts matching the given query.
Parameters:
query: The query to search for.limit: The maximum number of results to return.
Returns:
Result<Vec<Account>>: The fetched accounts.
Corresponds to GET /api/v1/accounts/search.
Sourcepub async fn relationships(&self, ids: &[String]) -> Result<Vec<Relationship>>
pub async fn relationships(&self, ids: &[String]) -> Result<Vec<Relationship>>
Fetches the relationship between the authenticated user and the given accounts.
Parameters:
ids: A list of account IDs to check relationships for.
Returns:
Result<Vec<crate::models::Relationship>>: The relationships.
Corresponds to GET /api/v1/accounts/relationships.