sword_layers/servedir/
config.rs1use console::style;
2use serde::{Deserialize, Serialize};
3
4use crate::DisplayConfig;
5
6#[derive(Clone, Debug, Deserialize, Serialize, Default)]
19pub struct ServeDirConfig {
20 pub enabled: bool,
21 pub static_dir: String,
22 pub router_path: String,
23 pub compression_algorithm: Option<String>,
24 pub chunk_size: Option<String>,
25 pub not_found_file: Option<String>,
26
27 #[serde(default)]
28 pub display: bool,
29}
30
31impl DisplayConfig for ServeDirConfig {
32 fn display(&self) {
33 if !self.display {
34 return;
35 }
36
37 println!("\n{}", style("Serve Directory Configuration:").bold());
38 println!(" ↳ Enabled: {}", self.enabled);
39 println!(" ↳ Static Directory: {}", self.static_dir);
40 println!(" ↳ Router Path: {}", self.router_path);
41
42 if let Some(algorithm) = &self.compression_algorithm {
43 println!(" ↳ Compression Algorithm: {algorithm}");
44 }
45 if let Some(chunk_size) = &self.chunk_size {
46 println!(" ↳ Chunk Size: {chunk_size}");
47 }
48 if let Some(not_found) = &self.not_found_file {
49 println!(" ↳ Not Found File: {not_found}");
50 }
51 }
52}