1use std::path::PathBuf;
4
5#[derive(Debug, Clone)]
7pub struct ServerConfig {
8 pub storage_dir: PathBuf,
10 pub max_artifact_size: u64,
12 pub bind_address: String,
14 pub port: u16,
16}
17
18impl Default for ServerConfig {
19 fn default() -> Self {
20 Self {
21 storage_dir: PathBuf::from("./cache"),
22 max_artifact_size: 1024 * 1024 * 1024, bind_address: "127.0.0.1".to_string(),
24 port: 8080,
25 }
26 }
27}
28
29impl ServerConfig {
30 pub fn new() -> Self {
32 Self::default()
33 }
34
35 pub fn with_storage_dir(mut self, dir: impl Into<PathBuf>) -> Self {
37 self.storage_dir = dir.into();
38 self
39 }
40
41 pub fn with_max_artifact_size(mut self, size: u64) -> Self {
43 self.max_artifact_size = size;
44 self
45 }
46
47 pub fn with_bind_address(mut self, address: impl Into<String>) -> Self {
49 self.bind_address = address.into();
50 self
51 }
52
53 pub fn with_port(mut self, port: u16) -> Self {
55 self.port = port;
56 self
57 }
58
59 pub fn bind_addr(&self) -> String {
61 format!("{}:{}", self.bind_address, self.port)
62 }
63}