some_random_api/endpoints/
animal.rs

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