dubp_documents/
revocation.rs1pub mod v10;
19
20use crate::*;
21
22pub use v10::{
23 CompactRevocationDocumentV10, CompactRevocationDocumentV10Stringified, RevocationDocumentV10,
24 RevocationDocumentV10Stringified,
25};
26
27#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
31pub enum RevocationDocument {
32 V10(RevocationDocumentV10),
34}
35
36#[derive(Debug, Copy, Clone, Deserialize, Serialize, PartialEq, Eq)]
40pub enum CompactRevocationDocument {
41 V10(CompactRevocationDocumentV10),
43}
44
45impl Document for RevocationDocument {
46 type PublicKey = PubKeyEnum;
47
48 #[inline]
49 fn version(&self) -> usize {
50 match self {
51 RevocationDocument::V10(revoc_10) => revoc_10.version(),
52 }
53 }
54
55 #[inline]
56 fn currency(&self) -> &str {
57 match self {
58 RevocationDocument::V10(revoc_v10) => revoc_v10.currency(),
59 }
60 }
61
62 #[inline]
63 fn blockstamp(&self) -> Blockstamp {
64 match self {
65 RevocationDocument::V10(revoc_v10) => revoc_v10.blockstamp(),
66 }
67 }
68
69 #[inline]
70 fn issuers(&self) -> SmallVec<[Self::PublicKey; 1]> {
71 match self {
72 RevocationDocument::V10(revoc_v10) => {
73 svec![PubKeyEnum::Ed25519(revoc_v10.issuers()[0])]
74 }
75 }
76 }
77
78 #[inline]
79 fn signatures(&self) -> SmallVec<[<Self::PublicKey as PublicKey>::Signature; 1]> {
80 match self {
81 RevocationDocument::V10(revoc_v10) => svec![Sig::Ed25519(revoc_v10.signatures()[0])],
82 }
83 }
84
85 #[inline]
86 fn as_bytes(&self) -> BeefCow<[u8]> {
87 match self {
88 RevocationDocument::V10(revoc_v10) => revoc_v10.as_bytes(),
89 }
90 }
91}
92
93#[derive(Clone, Debug, Deserialize, Serialize)]
94pub enum RevocationDocumentStringified {
95 V10(RevocationDocumentV10Stringified),
96}
97
98impl ToStringObject for RevocationDocument {
99 type StringObject = RevocationDocumentStringified;
100
101 fn to_string_object(&self) -> Self::StringObject {
102 match self {
103 RevocationDocument::V10(idty) => {
104 RevocationDocumentStringified::V10(idty.to_string_object())
105 }
106 }
107 }
108}
109
110#[derive(Clone, Debug, Deserialize, Serialize)]
111pub enum CompactRevocationDocumentStringified {
112 V10(CompactRevocationDocumentV10Stringified),
113}
114
115impl ToStringObject for CompactRevocationDocument {
116 type StringObject = CompactRevocationDocumentStringified;
117
118 fn to_string_object(&self) -> Self::StringObject {
119 match self {
120 CompactRevocationDocument::V10(doc) => {
121 CompactRevocationDocumentStringified::V10(doc.to_string_object())
122 }
123 }
124 }
125}