confium_deployment/identity/
attributes.rs1use std::collections::HashMap;
4
5use serde::{Deserialize, Serialize};
6
7#[derive(Debug, Clone, Default, Serialize, Deserialize)]
9pub struct SignerAttributes {
10 pub region: Option<String>,
12 pub expertise: Vec<String>,
14 pub nationality: Option<String>,
16 pub role: Vec<String>,
18 pub custom: HashMap<String, String>,
20}
21
22impl SignerAttributes {
23 pub fn new() -> Self {
25 Self::default()
26 }
27
28 pub fn with_region(mut self, region: impl Into<String>) -> Self {
30 self.region = Some(region.into());
31 self
32 }
33
34 pub fn with_expertise(mut self, expertise: impl Into<String>) -> Self {
36 self.expertise.push(expertise.into());
37 self
38 }
39
40 pub fn with_role(mut self, role: impl Into<String>) -> Self {
42 self.role.push(role.into());
43 self
44 }
45}
46
47#[cfg(test)]
48mod tests {
49 use super::*;
50
51 #[test]
52 fn build_attributes() {
53 let attrs = SignerAttributes::new()
54 .with_region("europe")
55 .with_expertise("metrology")
56 .with_role("director");
57 assert_eq!(attrs.region.as_deref(), Some("europe"));
58 assert_eq!(attrs.expertise, vec!["metrology"]);
59 assert_eq!(attrs.role, vec!["director"]);
60 }
61}