entrenar/research/artifact/
affiliation.rs1use serde::{Deserialize, Serialize};
4
5use super::{validate_ror_id, ValidationError};
6
7#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
9pub struct Affiliation {
10 pub name: String,
12 pub ror_id: Option<String>,
14 pub country: Option<String>,
16}
17
18impl Affiliation {
19 pub fn new(name: impl Into<String>) -> Self {
21 Self { name: name.into(), ror_id: None, country: None }
22 }
23
24 pub fn with_ror_id(mut self, ror_id: impl Into<String>) -> Result<Self, ValidationError> {
26 let ror = ror_id.into();
27 if !validate_ror_id(&ror) {
28 return Err(ValidationError::InvalidRorId(ror));
29 }
30 self.ror_id = Some(ror);
31 Ok(self)
32 }
33
34 pub fn with_country(mut self, country: impl Into<String>) -> Self {
36 self.country = Some(country.into());
37 self
38 }
39}