Oops on the Extension

This commit is contained in:
asonix 2020-03-18 20:57:39 -05:00
parent 39cfcf1373
commit f7e733c500
2 changed files with 20 additions and 2 deletions

View file

@ -15,7 +15,11 @@ pub struct PublicKey {
pub public_key_pem: String, pub public_key_pem: String,
} }
impl<T> Extension<T> for PublicKey where T: Actor {} #[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
#[serde(rename_all = "camelCase")]
pub struct PublicKeyExtension {
pub public_key: PublicKey,
}
#[derive(Clone, Debug, Default, serde::Deserialize, serde::Serialize, PropRefs)] #[derive(Clone, Debug, Default, serde::Deserialize, serde::Serialize, PropRefs)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
@ -86,6 +90,20 @@ pub struct Endpoints {
shared_inbox: Option<XsdAnyUri>, shared_inbox: Option<XsdAnyUri>,
} }
impl PublicKey {
pub fn to_ext(self) -> PublicKeyExtension {
self.into()
}
}
impl From<PublicKey> for PublicKeyExtension {
fn from(public_key: PublicKey) -> Self {
PublicKeyExtension { public_key }
}
}
impl<T> Extension<T> for PublicKeyExtension where T: Actor {}
impl ValidObjects { impl ValidObjects {
pub fn id(&self) -> &XsdAnyUri { pub fn id(&self) -> &XsdAnyUri {
match self { match self {

View file

@ -81,7 +81,7 @@ async fn actor_route(state: web::Data<State>) -> Result<impl Responder, MyError>
public_key_pem: state.settings.public_key.to_pem_pkcs8()?, public_key_pem: state.settings.public_key.to_pem_pkcs8()?,
}; };
Ok(ok(application.extend(public_key))) Ok(ok(application.extend(public_key.to_ext())))
} }
#[actix_rt::main] #[actix_rt::main]