1#[derive(Debug, Clone, PartialEq, Eq)]
5pub struct Config {
6 name: String,
7 description: Option<String>,
8}
9
10impl Config {
11 pub fn new(name: impl Into<String>) -> crate::Result<Self> {
17 let name = name.into();
18 if name.trim().is_empty() {
19 return Err(crate::CoreError::App(
20 "config name must not be empty".into(),
21 ));
22 }
23 Ok(Self {
24 name,
25 description: None,
26 })
27 }
28
29 #[must_use]
31 pub fn with_description(mut self, desc: impl Into<String>) -> Self {
32 self.description = Some(desc.into());
33 self
34 }
35
36 #[must_use]
38 pub fn name(&self) -> &str {
39 &self.name
40 }
41
42 #[must_use]
44 pub fn description(&self) -> Option<&str> {
45 self.description.as_deref()
46 }
47}