1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
use std::borrow::Cow;

use serde::{Deserialize, Serialize};

/// An author that might be developing
#[derive(Debug, Eq, PartialEq, Serialize, Deserialize, Clone)]
pub struct Author<'a> {
    name: Cow<'a, str>,
    email: Cow<'a, str>,
    #[serde(skip_serializing_if = "Option::is_none")]
    signingkey: Option<Cow<'a, str>>,
}

impl<'a> Author<'a> {
    /// Create a new author
    #[must_use]
    pub const fn new(
        name: Cow<'a, str>,
        email: Cow<'a, str>,
        signingkey: Option<Cow<'a, str>>,
    ) -> Self {
        Self {
            name,
            email,
            signingkey,
        }
    }

    /// The authors name
    #[must_use]
    pub fn name(&self) -> &str {
        &self.name
    }

    /// The authors email
    #[must_use]
    pub fn email(&self) -> &str {
        &self.email
    }

    /// The authors gpg key
    #[must_use]
    pub fn signingkey(&self) -> Option<&str> {
        self.signingkey.as_deref()
    }
}