Skip to content

Commit 90ebac8

Browse files
authored
chore: simplify snapshot status display impl with derive_more (#6473)
1 parent 6b48085 commit 90ebac8

File tree

1 file changed

+8
-23
lines changed

1 file changed

+8
-23
lines changed

src/rpc/methods/sync/types.rs

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,19 @@ use crate::lotus_json::lotus_json_with_self;
77
use schemars::JsonSchema;
88
use serde::{Deserialize, Serialize};
99

10-
#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
10+
#[derive(
11+
Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq, JsonSchema, derive_more::Display,
12+
)]
1113
#[serde(rename_all = "PascalCase")]
1214
pub enum SnapshotProgressState {
1315
#[default]
16+
#[display("🔄 Initializing (Checking if snapshot is needed)")]
1417
Initializing,
15-
InProgress {
16-
message: String,
17-
},
18+
#[display("🌳 In Progress: {message}")]
19+
InProgress { message: String },
20+
#[display("✅ Recently Completed! Chain will start syncing shortly")]
1821
Completed,
22+
#[display("⏳ Not Required (Snapshot is not needed)")]
1923
NotRequired,
2024
}
2125

@@ -41,25 +45,6 @@ impl SnapshotProgressState {
4145
}
4246
}
4347

44-
impl std::fmt::Display for SnapshotProgressState {
45-
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
46-
match self {
47-
Self::Initializing => {
48-
write!(f, "🔄 Initializing (Checking if snapshot is needed)")
49-
}
50-
Self::InProgress { message } => {
51-
write!(f, "🌳 In Progress: {message}")
52-
}
53-
Self::Completed => {
54-
write!(f, "✅ Recently Completed! Chain will start syncing shortly")
55-
}
56-
Self::NotRequired => {
57-
write!(f, "⏳ Not Required (Snapshot is not needed)")
58-
}
59-
}
60-
}
61-
}
62-
6348
lotus_json_with_self!(SnapshotProgressState);
6449

6550
#[derive(Default, Clone)]

0 commit comments

Comments
 (0)