blob: ea4f53e4f1a74843bc14bdd6336942c50bdd95a4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
use super::{ClientExt as _, Error};
use crate::model::RandomTeawie;
use std::future::Future;
const TEAWIE_API: &str = "https://api.getchoo.com";
pub trait ClientExt {
/// Get a random teawie
///
/// # Errors
///
/// Will return [`Err`] if the request fails or the response cannot be deserialized
fn random_teawie(&self) -> impl Future<Output = Result<Option<String>, Error>> + Send;
}
impl ClientExt for super::Client {
async fn random_teawie(&self) -> Result<Option<String>, Error> {
let url = format!("{TEAWIE_API}/random_teawie");
let resp: RandomTeawie = self.get_json(&url).await?;
Ok(resp.url)
}
}
|