mastodon_api\methods/
emojis.rs

1use crate::MastodonClient;
2use crate::error::Result;
3use crate::models::CustomEmoji;
4
5/// Handler for custom emoji API endpoints.
6pub struct EmojisHandler<'a> {
7    client: &'a MastodonClient,
8}
9
10impl<'a> EmojisHandler<'a> {
11    /// Creates a new `EmojisHandler` for the given client.
12    ///
13    /// Parameters:
14    /// - `client`: The client to use for making requests.
15    ///
16    /// Returns:
17    /// - `EmojisHandler`: The created emojis handler.
18    pub fn new(client: &'a MastodonClient) -> Self {
19        Self { client }
20    }
21
22    /// Fetches all custom emojis available on the instance.
23    ///
24    /// Returns:
25    /// - `Result<Vec<CustomEmoji>>`: The fetched custom emojis.
26    ///
27    /// Corresponds to `GET /api/v1/custom_emojis`.
28    pub async fn list(&self) -> Result<Vec<CustomEmoji>> {
29        let url = format!("{}/api/v1/custom_emojis", self.client.base_url());
30        let req = self.client.http_client().get(&url);
31        self.client.send(req).await
32    }
33}