some_random_api/endpoints/
image.rs

1use crate::{Image, Requester};
2use anyhow::Result;
3
4/// An endpoint that sends a random image of an animal
5///
6/// # Examples
7///
8/// ```
9/// use some_random_api::Client;
10///
11/// Client::new(None::<String>).image.bird().await?;
12/// ```
13pub struct ImageEndpoint(pub(crate) Requester);
14
15impl ImageEndpoint {
16    /// An endpoint that sends a random image of a bird
17    pub async fn bird(&self) -> Result<Image> {
18        self.0.request("img/bird", None::<&()>).await
19    }
20
21    /// An endpoint that sends a random image of a cat
22    pub async fn cat(&self) -> Result<Image> {
23        self.0.request("img/cat", None::<&()>).await
24    }
25
26    /// An endpoint that sends a random image of a dog
27    pub async fn dog(&self) -> Result<Image> {
28        self.0.request("img/dog", None::<&()>).await
29    }
30
31    /// An endpoint that sends a random image of a fox
32    pub async fn fox(&self) -> Result<Image> {
33        self.0.request("img/fox", None::<&()>).await
34    }
35
36    /// An endpoint that sends a random image of a kangaroo
37    pub async fn kangaroo(&self) -> Result<Image> {
38        self.0.request("img/fox", None::<&()>).await
39    }
40
41    /// An endpoint that sends a random image of a koala
42    pub async fn koala(&self) -> Result<Image> {
43        self.0.request("img/koala", None::<&()>).await
44    }
45
46    /// An endpoint that sends a random image of a panda
47    pub async fn panda(&self) -> Result<Image> {
48        self.0.request("img/panda", None::<&()>).await
49    }
50
51    /// An endpoint that sends a random image of a pikachu
52    pub async fn pikachu(&self) -> Result<Image> {
53        self.0.request("img/pikachu", None::<&()>).await
54    }
55
56    /// An endpoint that sends a random image of a raccoon
57    pub async fn raccoon(&self) -> Result<Image> {
58        self.0.request("img/raccoon", None::<&()>).await
59    }
60
61    /// An endpoint that sends a random image of a red panda
62    pub async fn red_panda(&self) -> Result<Image> {
63        self.0.request("img/red_panda", None::<&()>).await
64    }
65
66    /// An endpoint that sends a random image of a whale
67    pub async fn whale(&self) -> Result<Image> {
68        self.0.request("img/whale", None::<&()>).await
69    }
70}