dpp_domain/personal_data/record_id.rs
1//! [`PersonalDataRecordId`] — names a record of personal data held outside a
2//! passport.
3
4use serde::{Deserialize, Serialize};
5
6/// Identifies a record of personal data held outside a passport, through the
7/// `PersonalDataPort` in the ports module.
8///
9/// Opaque, and minted by whoever holds the record. It goes into a signed,
10/// retention-locked passport, where it outlives the record it names, so it must
11/// carry nothing derived from the data or from the person: once the record is
12/// erased, the identifier left in the passport must say nothing about anyone.
13#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
14#[serde(transparent)]
15pub struct PersonalDataRecordId(String);
16
17impl PersonalDataRecordId {
18 /// Wrap an identifier minted by the record's holder.
19 #[must_use]
20 pub fn new(id: impl Into<String>) -> Self {
21 Self(id.into())
22 }
23
24 /// The identifier as written.
25 #[must_use]
26 pub fn as_str(&self) -> &str {
27 &self.0
28 }
29}
30
31impl std::fmt::Display for PersonalDataRecordId {
32 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
33 f.write_str(&self.0)
34 }
35}