libnsave/
configure.rs

1use crate::common::StoreError;
2use serde::Deserialize;
3use std::fs;
4use std::path::Path;
5
6#[derive(Debug, Deserialize)]
7pub struct Configure {
8    pub interface: String,
9    pub pkt_len: i32,
10    pub filter: Option<String>,
11    pub daemon: bool,
12    pub pcap_file: Option<String>,
13    pub store_path: String,
14    pub thread_num: u64,
15    pub pkt_channel_size: usize,
16    pub msg_channel_size: usize,
17    pub timer_intervel: usize,
18    pub writer_empty_sleep: usize,
19    pub clean_empty_sleep: usize,
20    pub pool_size: u64,
21    pub file_size: u64,
22    pub chunk_size: u32,
23    pub ci_buff_size: u64,
24    pub ti_buff_size: u64,
25    pub flow_max_table_capacity: usize,
26    pub flow_node_timeout: usize,
27    pub flow_max_seq_gap: usize,
28}
29
30impl Configure {
31    pub fn load(file_path: &Path) -> Result<&'static Configure, StoreError> {
32        let toml_str = fs::read_to_string(file_path).expect("Failed to read configure file");
33        let configure: Configure =
34            toml::from_str(&toml_str).expect("Failed to deserialize configure file");
35        return Ok(Box::leak(Box::new(configure)));
36    }
37}