1use serde::{Deserialize, Serialize};
11
12#[derive(Serialize, Deserialize, Clone, Debug)]
14pub enum CheckpointData {
15 V1(iota_types::full_checkpoint_content::CheckpointData),
16}
17
18#[derive(Serialize, Deserialize, Clone, Debug)]
20pub enum CertifiedCheckpointSummary {
21 V1(iota_types::messages_checkpoint::CertifiedCheckpointSummary),
22}
23
24impl From<iota_types::full_checkpoint_content::CheckpointData> for CheckpointData {
25 fn from(data: iota_types::full_checkpoint_content::CheckpointData) -> Self {
26 Self::V1(data)
27 }
28}
29
30impl From<iota_types::messages_checkpoint::CertifiedCheckpointSummary>
31 for CertifiedCheckpointSummary
32{
33 fn from(summary: iota_types::messages_checkpoint::CertifiedCheckpointSummary) -> Self {
34 Self::V1(summary)
35 }
36}
37
38impl CheckpointData {
39 pub fn into_v1(self) -> Option<iota_types::full_checkpoint_content::CheckpointData> {
41 match self {
42 Self::V1(data) => Some(data),
43 }
44 }
45
46 pub fn as_v1(&self) -> Option<&iota_types::full_checkpoint_content::CheckpointData> {
49 match self {
50 Self::V1(data) => Some(data),
51 }
52 }
53
54 pub fn sequence_number(&self) -> u64 {
56 match self {
57 Self::V1(data) => data.checkpoint_summary.sequence_number,
58 }
59 }
60}
61
62impl CertifiedCheckpointSummary {
63 pub fn into_v1(self) -> Option<iota_types::messages_checkpoint::CertifiedCheckpointSummary> {
65 match self {
66 Self::V1(summary) => Some(summary),
67 }
68 }
69
70 pub fn as_v1(&self) -> Option<&iota_types::messages_checkpoint::CertifiedCheckpointSummary> {
73 match self {
74 Self::V1(summary) => Some(summary),
75 }
76 }
77
78 pub fn sequence_number(&self) -> u64 {
80 match self {
81 Self::V1(summary) => summary.data().sequence_number,
82 }
83 }
84}