31 lines
857 B
Rust
31 lines
857 B
Rust
|
// For this example, we'll use the Extensible trait, the Extension trait, the Actor trait, and
|
||
|
// the Person type
|
||
|
use activitystreams::{actor::Actor, ext::Extension};
|
||
|
|
||
|
// The following is taken from here:
|
||
|
// https://docs.rs/activitystreams/0.5.0-alpha.17/activitystreams/ext/index.html
|
||
|
|
||
|
#[derive(Clone, Debug, Default, serde::Deserialize, serde::Serialize)]
|
||
|
#[serde(rename_all = "camelCase")]
|
||
|
pub struct PublicKey {
|
||
|
pub id: String,
|
||
|
pub owner: String,
|
||
|
pub public_key_pem: String,
|
||
|
}
|
||
|
|
||
|
#[derive(Clone, Debug, Default, serde::Deserialize, serde::Serialize)]
|
||
|
#[serde(rename_all = "camelCase")]
|
||
|
pub struct PublicKeyExtension {
|
||
|
pub public_key: PublicKey,
|
||
|
}
|
||
|
|
||
|
impl PublicKey {
|
||
|
pub fn to_ext(&self) -> PublicKeyExtension {
|
||
|
PublicKeyExtension {
|
||
|
public_key: self.to_owned(),
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
impl<T> Extension<T> for PublicKeyExtension where T: Actor {}
|