1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
use did::{Document, PublicKey, Service}; use serde::{ser::SerializeMap, Serialize}; #[macro_use] extern crate bitflags; #[derive(Debug, Serialize, Clone)] pub struct Delta { patches: Vec<Patch>, update_commitment: String, } #[derive(Debug, Serialize, Clone)] pub struct SuffixData { #[serde(rename = "deltaHash")] delta_hash: String, #[serde(rename = "recoveryCommitment")] recovery_commitment: String, #[serde(rename = "type", skip_serializing_if = "Option::is_none")] data_type: Option<String>, } #[derive(Debug, Clone)] pub enum Patch { AddPublicKeys(Vec<PublicKey>), RemovePublicKeys(Vec<String>), AddServices(Vec<Service>), RemoveServices(Vec<String>), Replace(Document), IetfJsonPatch, } impl Serialize for Patch { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, { let mut map = serializer.serialize_map(None)?; match self { Patch::AddPublicKeys(public_keys) => { map.serialize_entry("action", "add-public-keys")?; map.serialize_entry("publicKeys", public_keys)?; } Patch::RemovePublicKeys(_) => {} Patch::AddServices(_) => {} Patch::RemoveServices(_) => {} Patch::Replace(document) => { map.serialize_entry("action", "replace")?; map.serialize_entry("document", document)?; } Patch::IetfJsonPatch => {} } map.end() } } #[derive(Debug, Clone, PartialEq)] pub struct Error {} mod did; mod encoder; mod multihash; pub mod operations; pub mod secp256k1;