telegram_bot_fork_raw/requests/_base/
http.rs1use url::TELEGRAM_URL;
2
3#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
4pub enum RequestUrl {
5 Method(&'static str),
6}
7
8impl RequestUrl {
9 pub fn method(method: &'static str) -> Self {
10 RequestUrl::Method(method)
11 }
12
13 pub fn url(&self, url: Option<&str>, token: &str) -> String {
14 match *self {
15 RequestUrl::Method(method) => {
16 format!("{}bot{}/{}", url.unwrap_or(TELEGRAM_URL), token, method)
17 }
18 }
19 }
20}
21
22#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
23pub enum Method {
24 Get,
25 Post,
26}
27
28#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
29pub enum Body {
30 Empty,
31 Json(Vec<u8>),
32 #[doc(hidden)]
33 __Nonexhaustive,
34}
35
36#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
37pub struct HttpRequest {
38 pub url: RequestUrl,
39 pub method: Method,
40 pub body: Body,
41}
42
43#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
44pub struct HttpResponse {
45 pub body: Option<Vec<u8>>,
46}