mastodon_api\methods/
trends.rs

1use crate::MastodonClient;
2use crate::error::Result;
3use crate::models::{Status, Tag};
4
5/// Handler for trending content API endpoints.
6pub struct TrendsHandler<'a> {
7    client: &'a MastodonClient,
8}
9
10impl<'a> TrendsHandler<'a> {
11    pub fn new(client: &'a MastodonClient) -> Self {
12        Self { client }
13    }
14
15    /// Fetches trending hashtags.
16    ///
17    /// Corresponds to `GET /api/v1/trends/tags`.
18    pub async fn tags(&self) -> Result<Vec<Tag>> {
19        let url = format!("{}/api/v1/trends/tags", self.client.base_url());
20        let req = self.client.http_client().get(&url);
21        self.client.send(req).await
22    }
23
24    /// Fetches trending statuses.
25    ///
26    /// Corresponds to `GET /api/v1/trends/statuses`.
27    pub async fn statuses(&self) -> Result<Vec<Status>> {
28        let url = format!("{}/api/v1/trends/statuses", self.client.base_url());
29        let req = self.client.http_client().get(&url);
30        self.client.send(req).await
31    }
32}