Skip to content

Commit d84d29c

Browse files
Implement Debug for ProblemReport and simplify serialization (#173)
1 parent 78dfbba commit d84d29c

File tree

2 files changed

+7
-18
lines changed

2 files changed

+7
-18
lines changed

rust/catalyst-types/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ fluent-uri = "0.3.2"
2323
hex = "0.4.3"
2424
minicbor = { version = "0.25.1", features = ["std"] }
2525
num-traits = "0.2.19"
26-
orx-concurrent-vec = "3.1.0"
26+
orx-concurrent-vec = { version = "3.2.0", features = ["serde"] }
2727
pallas-crypto = { version = "0.30.1", git = "https://github.com/input-output-hk/catalyst-pallas.git", rev = "9b5183c8b90b90fe2cc319d986e933e9518957b3" }
2828
serde = { version = "1.0.217", features = ["derive", "rc"] }
2929
thiserror = "2.0.9"

rust/catalyst-types/src/problem_report.rs

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
use std::sync::Arc;
88

99
use orx_concurrent_vec::ConcurrentVec;
10-
use serde::{ser::SerializeSeq, Serialize};
10+
use serde::Serialize;
1111

1212
/// The kind of problem being reported
13-
#[derive(Serialize, Clone)]
13+
#[derive(Debug, Serialize, Clone)]
1414
#[serde(tag = "type")]
1515
enum Kind {
1616
/// Expected and Required field is missing
@@ -73,7 +73,7 @@ enum Kind {
7373
}
7474

7575
/// Problem Report Entry
76-
#[derive(Serialize, Clone)]
76+
#[derive(Debug, Serialize, Clone)]
7777
struct Entry {
7878
/// The kind of problem we are recording.
7979
kind: Kind,
@@ -82,22 +82,11 @@ struct Entry {
8282
}
8383

8484
/// The Problem Report list
85-
#[derive(Clone)]
85+
#[derive(Debug, Clone, Serialize)]
8686
struct Report(ConcurrentVec<Entry>);
8787

88-
impl Serialize for Report {
89-
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
90-
where S: serde::Serializer {
91-
let mut seq = serializer.serialize_seq(Some(self.0.len()))?;
92-
for e in self.0.iter_cloned() {
93-
seq.serialize_element(&e)?;
94-
}
95-
seq.end()
96-
}
97-
}
98-
9988
/// An inner state of the report.
100-
#[derive(Serialize)]
89+
#[derive(Debug, Serialize)]
10190
struct State {
10291
/// What context does the whole report have
10392
context: String,
@@ -108,7 +97,7 @@ struct State {
10897
/// Problem Report.
10998
///
11099
/// This structure allows making a cheap copies that share the same state.
111-
#[derive(Clone, Serialize)]
100+
#[derive(Debug, Clone, Serialize)]
112101
pub struct ProblemReport(Arc<State>);
113102

114103
impl ProblemReport {

0 commit comments

Comments
 (0)