lattice_sdk/core/
request_options.rs1use std::collections::HashMap;
2#[derive(Debug, Clone, Default)]
4pub struct RequestOptions {
5 pub api_key: Option<String>,
7 pub token: Option<String>,
9 pub max_retries: Option<u32>,
11 pub timeout_seconds: Option<u64>,
13 pub additional_headers: HashMap<String, String>,
15 pub additional_query_params: HashMap<String, String>,
17}
18
19impl RequestOptions {
20 pub fn new() -> Self {
21 Self::default()
22 }
23
24 pub fn api_key(mut self, key: impl Into<String>) -> Self {
25 self.api_key = Some(key.into());
26 self
27 }
28
29 pub fn token(mut self, token: impl Into<String>) -> Self {
30 self.token = Some(token.into());
31 self
32 }
33
34 pub fn max_retries(mut self, retries: u32) -> Self {
35 self.max_retries = Some(retries);
36 self
37 }
38
39 pub fn timeout_seconds(mut self, timeout: u64) -> Self {
40 self.timeout_seconds = Some(timeout);
41 self
42 }
43
44 pub fn additional_header(mut self, key: impl Into<String>, value: impl Into<String>) -> Self {
45 self.additional_headers.insert(key.into(), value.into());
46 self
47 }
48
49 pub fn additional_query_param(
50 mut self,
51 key: impl Into<String>,
52 value: impl Into<String>,
53 ) -> Self {
54 self.additional_query_params
55 .insert(key.into(), value.into());
56 self
57 }
58}