1use super::*;
2
3#[derive(Debug, Clone, PartialEq, Eq)]
7pub struct FetchBuilder<'a> {
8 url: &'a str,
9 method: Method,
10 headers: Vec<Header<'a>>,
11 data: Vec<u8>,
12}
13
14impl<'a> FetchBuilder<'a> {
15 pub fn method(mut self, method: Method) -> Self {
17 self.method = method;
18
19 self
20 }
21
22 pub fn body(mut self, data: impl Into<Vec<u8>>) -> Self {
24 self.data = data.into();
25
26 self
27 }
28
29 pub fn header(mut self, header: Header<'a>) -> Self {
31 self.headers.push(header);
32
33 self
34 }
35
36 pub fn fetch(self) -> Fetch {
38 Fetch::new(self.url, self.method, self.headers, self.data)
39 }
40
41 pub(crate) fn new(url: &'a str) -> Self {
42 Self {
43 url,
44 method: Method::Get,
45 headers: Vec::new(),
46 data: Vec::new(),
47 }
48 }
49}