vos_core/schema/authors/
mod.rs1use super::*;
2
3#[derive(Clone, Debug, Serialize, Deserialize)]
4pub struct ProjectAuthor {
5 pub name: String,
6 pub email: EmailAddress,
8 #[serde(flatten)]
9 pub extra: BTreeMap<String, Object>,
10}
11
12impl Eq for ProjectAuthor {}
13
14impl PartialEq<Self> for ProjectAuthor {
15 fn eq(&self, other: &Self) -> bool {
16 self.email.eq(&other.email)
17 }
18}
19
20impl PartialOrd<Self> for ProjectAuthor {
21 fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
22 self.name.partial_cmp(&other.name)
23 }
24}
25
26impl Ord for ProjectAuthor {
27 fn cmp(&self, other: &Self) -> Ordering {
28 self.name.cmp(&other.name)
29 }
30}
31
32impl ProjectAuthor {
33 pub fn new(name: &str, email: &str) -> VosResult<Self> {
34 if name.is_empty() {
35 return Err(VosError::parse_error("Project author missing name"));
36 }
37 if email.is_empty() {
38 return Err(VosError::parse_error("Project author missing email"));
39 }
40 let email = EmailAddress::from_str(email)?;
41 Ok(Self { name: name.to_owned(), email, extra: Default::default() })
42 }
43
44 pub fn insert<K, V>(&mut self, key: K, value: V) -> Option<Object>
45 where
46 K: Into<String>,
47 V: Into<Object>,
48 {
49 self.extra.insert(key.into(), value.into())
50 }
51
52 pub fn short_name(&self) -> bool {
53 todo!()
54 }
55}