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