1use serde::Deserialize;
2use thiserror::Error;
3
4mod blocking_req;
5pub use blocking_req::*;
6
7#[cfg(feature = "async")]
8mod async_req;
9#[cfg(feature = "async")]
10pub use async_req::*;
11
12#[derive(Debug, Deserialize)]
13pub struct Inbox {
14 pub address: String,
15 pub token: String,
16}
17
18#[derive(Debug, Deserialize)]
19#[serde(untagged)]
20enum DomainInboxResponse {
21 Success(Inbox),
22 #[allow(dead_code)]
23 Error { error: String }
24}
25
26#[derive(Debug, Deserialize)]
27pub struct Email {
28 pub from: String,
29 pub to: String,
30 pub subject: String,
31 pub body: String,
32 pub html: Option<String>,
33 pub date: i64,
34 pub ip: String,
35}
36
37#[derive(Debug, Deserialize)]
38#[serde(untagged)]
39enum EmailsResponse {
40 Success{ email: Vec<Email> },
41 #[allow(dead_code)]
42 Error { token: String }
43}
44
45#[derive(Debug, Error)]
46pub enum TempMailError {
47 #[error("request failed")]
48 RequestError(#[from] reqwest::Error),
49 #[error("invalid domain")]
50 InvalidDomain,
51 #[error("invalid token")]
52 InvalidToken,
53}
54
55const BASE_URL: &str = "https://api.tempmail.lol";
56