dubp_documents/
identity.rs1pub mod v10;
19
20pub use v10::{IdentityDocumentV10, IdentityDocumentV10Builder, IdentityDocumentV10Stringified};
21
22use crate::*;
23
24#[derive(Clone, Debug, Deserialize, Hash, Serialize, PartialEq, Eq)]
26pub enum IdentityDocument {
27 V10(IdentityDocumentV10),
29}
30
31impl Document for IdentityDocument {
32 type PublicKey = PubKeyEnum;
33
34 #[inline]
35 fn version(&self) -> usize {
36 match self {
37 IdentityDocument::V10(idty_v10) => idty_v10.version(),
38 }
39 }
40
41 #[inline]
42 fn currency(&self) -> &str {
43 match self {
44 IdentityDocument::V10(idty_v10) => idty_v10.currency(),
45 }
46 }
47
48 #[inline]
49 fn blockstamp(&self) -> Blockstamp {
50 match self {
51 IdentityDocument::V10(idty_v10) => idty_v10.blockstamp(),
52 }
53 }
54
55 #[inline]
56 fn issuers(&self) -> SmallVec<[Self::PublicKey; 1]> {
57 match self {
58 IdentityDocument::V10(idty_v10) => svec![PubKeyEnum::Ed25519(idty_v10.issuers()[0])],
59 }
60 }
61
62 #[inline]
63 fn signatures(&self) -> SmallVec<[<Self::PublicKey as PublicKey>::Signature; 1]> {
64 match self {
65 IdentityDocument::V10(idty_v10) => svec![Sig::Ed25519(idty_v10.signatures()[0])],
66 }
67 }
68
69 #[inline]
70 fn as_bytes(&self) -> BeefCow<[u8]> {
71 match self {
72 IdentityDocument::V10(idty_v10) => idty_v10.as_bytes(),
73 }
74 }
75}
76
77#[derive(Clone, Debug, Deserialize, Serialize)]
78pub enum IdentityDocumentStringified {
79 V10(IdentityDocumentV10Stringified),
80}
81
82impl ToStringObject for IdentityDocument {
83 type StringObject = IdentityDocumentStringified;
84
85 fn to_string_object(&self) -> Self::StringObject {
86 match self {
87 IdentityDocument::V10(idty) => {
88 IdentityDocumentStringified::V10(idty.to_string_object())
89 }
90 }
91 }
92}