2024-03-21 02:11:31 +01:00
|
|
|
// TODO technically this is not part of ActivityStreams
|
|
|
|
|
|
|
|
pub trait PublicKey : super::Base {
|
2024-06-01 01:04:03 +02:00
|
|
|
fn owner(&self) -> crate::Field<&str> { Err(crate::FieldErr("owner")) }
|
2024-03-21 02:11:31 +01:00
|
|
|
fn public_key_pem(&self) -> &str;
|
|
|
|
}
|
|
|
|
|
|
|
|
pub trait PublicKeyMut : super::BaseMut {
|
|
|
|
fn set_owner(self, val: Option<&str>) -> Self;
|
|
|
|
fn set_public_key_pem(self, val: &str) -> Self;
|
|
|
|
}
|
|
|
|
|
2024-04-06 18:04:14 +02:00
|
|
|
#[cfg(feature = "unstructured")]
|
2024-03-21 02:11:31 +01:00
|
|
|
impl PublicKey for serde_json::Value {
|
2024-04-06 18:04:14 +02:00
|
|
|
crate::getter! { owner -> &str }
|
2024-03-21 02:11:31 +01:00
|
|
|
|
|
|
|
fn public_key_pem(&self) -> &str {
|
2024-05-02 13:16:37 +02:00
|
|
|
self.get("publicKeyPem").map(|x| x.as_str().unwrap_or_default()).unwrap_or_default()
|
2024-03-21 02:11:31 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-06 18:04:14 +02:00
|
|
|
#[cfg(feature = "unstructured")]
|
2024-03-21 02:11:31 +01:00
|
|
|
impl PublicKeyMut for serde_json::Value {
|
2024-04-06 18:04:14 +02:00
|
|
|
crate::setter! { owner -> &str }
|
2024-03-21 02:11:31 +01:00
|
|
|
|
|
|
|
fn set_public_key_pem(mut self, val: &str) -> Self {
|
|
|
|
self.as_object_mut().unwrap().insert(
|
|
|
|
"publicKeyPem".to_string(),
|
|
|
|
serde_json::Value::String(val.to_string()),
|
|
|
|
);
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|