Skip to main content

orator_core/
config.rs

1/// Configuration for code generation.
2#[derive(Debug, Clone)]
3pub struct Config {
4    pub header_params: bool,
5    pub cookie_params: bool,
6}
7
8impl Default for Config {
9    fn default() -> Self {
10        Self {
11            header_params: true,
12            cookie_params: true,
13        }
14    }
15}
16
17impl Config {
18    pub fn header_params(mut self, enabled: bool) -> Self {
19        self.header_params = enabled;
20        self
21    }
22
23    pub fn cookie_params(mut self, enabled: bool) -> Self {
24        self.cookie_params = enabled;
25        self
26    }
27
28    pub fn is_location_enabled(&self, location: &crate::ir::ParamLocation) -> bool {
29        match location {
30            crate::ir::ParamLocation::Path | crate::ir::ParamLocation::Query => true,
31            crate::ir::ParamLocation::Header => self.header_params,
32            crate::ir::ParamLocation::Cookie => self.cookie_params,
33        }
34    }
35}