#[derive(Clone, Eq, Hash, PartialEq, Debug)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(untagged))]
pub enum PseudonymizationDomain {
#[cfg(feature = "global-pseudonyms")]
Global,
#[cfg(feature = "legacy")]
Specific { payload: String, audience_type: u32 },
#[cfg(not(feature = "legacy"))]
Specific(String),
}
#[derive(Clone, Eq, Hash, PartialEq, Debug)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(untagged))]
pub enum EncryptionContext {
#[cfg(feature = "offline")]
Global,
#[cfg(feature = "legacy")]
Specific { payload: String, audience_type: u32 },
#[cfg(not(feature = "legacy"))]
Specific(String),
}
impl PseudonymizationDomain {
#[cfg(feature = "legacy")]
pub fn from(payload: &str) -> Self {
PseudonymizationDomain::Specific {
payload: payload.to_string(),
audience_type: 0,
}
}
#[cfg(not(feature = "legacy"))]
pub fn from(payload: &str) -> Self {
PseudonymizationDomain::Specific(payload.to_string())
}
#[cfg(feature = "global-pseudonyms")]
pub fn global() -> Self {
PseudonymizationDomain::Global
}
#[cfg(feature = "legacy")]
pub fn from_audience(payload: &str, audience_type: u32) -> Self {
PseudonymizationDomain::Specific {
payload: payload.to_string(),
audience_type,
}
}
}
impl EncryptionContext {
#[cfg(feature = "legacy")]
pub fn from(payload: &str) -> Self {
EncryptionContext::Specific {
payload: payload.to_string(),
audience_type: 0,
}
}
#[cfg(not(feature = "legacy"))]
pub fn from(payload: &str) -> Self {
EncryptionContext::Specific(payload.to_string())
}
#[cfg(feature = "offline")]
pub fn global() -> Self {
EncryptionContext::Global
}
#[cfg(feature = "legacy")]
pub fn from_audience(payload: &str, audience_type: u32) -> Self {
EncryptionContext::Specific {
payload: payload.to_string(),
audience_type,
}
}
}