Skip to main content

muster/domain/value/
description.rs

1use nutype::nutype;
2
3/// Optional secondary line shown under a process name in the sidebar: trimmed
4/// and non-empty. Wrap in `Option` for the absent case.
5#[nutype(
6    sanitize(trim),
7    validate(not_empty),
8    derive(
9        Debug,
10        Clone,
11        PartialEq,
12        Eq,
13        Hash,
14        AsRef,
15        Display,
16        Serialize,
17        Deserialize
18    )
19)]
20pub struct Description(String);
21
22#[cfg(test)]
23mod tests {
24    use super::*;
25
26    #[test]
27    fn rejects_blank() {
28        assert!(Description::try_new("  ").is_err());
29    }
30
31    #[test]
32    fn accepts_a_sentence() {
33        let d = Description::try_new("A CLI interface for the project").unwrap();
34        assert_eq!(d.as_ref(), "A CLI interface for the project");
35    }
36}