laravel_template_engine/config.rs
1//! The package's settings.
2
3use laravel::config::Section;
4
5/// The package's settings, read from the environment. Every one has a default, so nothing needs
6/// to be set. An application changes them in `with_config`:
7///
8/// ```no_run
9/// # use laravel::Application;
10/// use laravel_template_engine::TemplateEngineConfig;
11///
12/// # let _ =
13/// Application::configure().with_config(|config, _| {
14/// config.section_mut::<TemplateEngineConfig>().locale = "uk".into();
15/// })
16/// # ;
17/// ```
18#[derive(Debug, Clone, Section)]
19pub struct TemplateEngineConfig {
20 /// The language used when a recipient's language has no text in the template.
21 #[env("TEMPLATE_ENGINE_LOCALE", default = "en".to_owned())]
22 pub locale: String,
23 /// The currency `| money` uses when a template doesn't name one.
24 #[env("TEMPLATE_ENGINE_CURRENCY", default = "USD".to_owned())]
25 pub currency: String,
26 /// The queue connection messages go through. Empty means the application's default.
27 #[env("TEMPLATE_ENGINE_QUEUE_CONNECTION")]
28 pub queue_connection: Option<String>,
29 /// The queue messages go on. Empty means the connection's default.
30 #[env("TEMPLATE_ENGINE_QUEUE")]
31 pub queue: Option<String>,
32 /// How much work one render may do: roughly the number of steps, loop iterations included.
33 #[env("TEMPLATE_ENGINE_FUEL", default = 2_000_000)]
34 pub fuel: u64,
35 /// The most bytes one render may write.
36 #[env("TEMPLATE_ENGINE_MAX_OUTPUT", default = 2 * 1024 * 1024)]
37 pub max_output: usize,
38 /// The longest one render may take, in milliseconds.
39 #[env("TEMPLATE_ENGINE_TIMEOUT_MS", default = 2_000)]
40 pub timeout_ms: u64,
41 /// How deeply `if` and `for` blocks may nest.
42 #[env("TEMPLATE_ENGINE_MAX_DEPTH", default = 10)]
43 pub max_depth: usize,
44 /// The most characters a template's text may have.
45 #[env("TEMPLATE_ENGINE_MAX_LENGTH", default = 200_000)]
46 pub max_length: usize,
47 /// What a test send puts in front of the subject.
48 #[env("TEMPLATE_ENGINE_TEST_PREFIX", default = "[Test] ".to_owned())]
49 pub test_prefix: String,
50}
51
52pub(crate) fn config() -> TemplateEngineConfig {
53 laravel::config().section::<TemplateEngineConfig>().clone()
54}