Skip to main content

sim_table_http/
citizen.rs

1//! Citizen descriptor for the HTTP directory class.
2
3use sim_citizen_derive::Citizen;
4use sim_kernel::Symbol;
5
6/// Serialized configuration for an [`HttpDir`](crate::HttpDir).
7#[derive(Clone, Debug, PartialEq, Citizen)]
8#[citizen(symbol = "table/HttpDir", version = 0)]
9pub struct HttpDirDescriptor {
10    /// Base URL whose children are addressed by table keys.
11    pub base_url: String,
12    /// Codec used to decode response bodies and encode request bodies.
13    pub codec: Symbol,
14    /// Write method used by `set`, either `PUT` or `POST`.
15    pub write_method: String,
16    /// Socket read/write timeout in milliseconds.
17    pub timeout_ms: u64,
18    /// Maximum response body size in bytes.
19    pub max_body_bytes: usize,
20}
21
22impl Default for HttpDirDescriptor {
23    fn default() -> Self {
24        Self {
25            base_url: String::new(),
26            codec: Symbol::qualified("codec", "lisp"),
27            write_method: "PUT".to_owned(),
28            timeout_ms: 5_000,
29            max_body_bytes: 1024 * 1024,
30        }
31    }
32}
33
34/// The fully qualified class symbol (`table/HttpDir`) for the HTTP directory.
35pub fn http_dir_class_symbol() -> Symbol {
36    Symbol::qualified("table", "HttpDir")
37}