mit_commit_message_lints/mit/lib/
author.rs

1use std::borrow::Cow;
2
3use serde::{Deserialize, Serialize};
4
5/// An author that might be developing
6#[derive(Debug, Eq, PartialEq, Serialize, Deserialize, Clone)]
7pub struct Author<'a> {
8    name: Cow<'a, str>,
9    email: Cow<'a, str>,
10    #[serde(skip_serializing_if = "Option::is_none")]
11    signingkey: Option<Cow<'a, str>>,
12}
13
14impl<'a> Author<'a> {
15    /// Create a new author
16    #[must_use]
17    pub const fn new(
18        name: Cow<'a, str>,
19        email: Cow<'a, str>,
20        signingkey: Option<Cow<'a, str>>,
21    ) -> Self {
22        Self {
23            name,
24            email,
25            signingkey,
26        }
27    }
28
29    /// The author name
30    #[must_use]
31    pub fn name(&self) -> &str {
32        &self.name
33    }
34
35    /// The authors email
36    #[must_use]
37    pub fn email(&self) -> &str {
38        &self.email
39    }
40
41    /// The authors gpg key
42    #[must_use]
43    pub fn signingkey(&self) -> Option<&str> {
44        self.signingkey.as_deref()
45    }
46}