Parakeet is a Rust-based Bluesky AppView aiming to implement most of the functionality required to support the Bluesky client
at main 1.3 kB view raw
1use serde::Deserialize; 2 3#[derive(Debug, Deserialize)] 4#[serde(rename_all = "camelCase")] 5pub struct DidDocument { 6 #[serde(default, rename = "@context")] 7 pub context: Vec<String>, 8 pub id: String, 9 /// Ordered set (no duplicates) of aliases and names for this account, in the form of URIs 10 pub also_known_as: Option<Vec<String>>, 11 pub service: Option<Vec<DidService>>, 12 pub verification_method: Option<Vec<DidVerificationMethod>>, 13} 14 15impl DidDocument { 16 pub fn find_service_by_id(&self, service: &str) -> Option<&DidService> { 17 self.service 18 .as_ref() 19 .and_then(|services| services.iter().find(|s| s.id == service)) 20 } 21 22 pub fn find_verif_method_by_type(&self, ty: &str) -> Option<&DidVerificationMethod> { 23 self.verification_method 24 .as_ref() 25 .and_then(|methods| methods.iter().find(|m| m.ty == ty)) 26 } 27} 28 29#[derive(Debug, Deserialize)] 30#[serde(rename_all = "camelCase")] 31pub struct DidService { 32 pub id: String, 33 #[serde(rename = "type")] 34 pub ty: String, 35 pub service_endpoint: String, 36} 37 38#[derive(Debug, Deserialize)] 39#[serde(rename_all = "camelCase")] 40pub struct DidVerificationMethod { 41 pub id: String, 42 #[serde(rename = "type")] 43 pub ty: String, 44 pub controller: String, 45 pub public_key_multibase: String, 46}