Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fmt::Display output for Status is now valid JSON #536

Merged
merged 1 commit into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Added `FetchCanisterLogs` function to `MgmtMethod` and a corresponding wrapper to `ManagementCanister`.
* Updated the `ring` crate to 0.17.7. `ring` 0.16 has a bug where it requires incorrect Ed25519 PEM encoding. 0.17.7 fixes that and is backwards compatible.
* Removed serde and candid serialization traits from the `Status` type.
* Added commas and newlines to the `Status` fmt::Display output. It is valid JSON now (it was close before).

## [0.33.0] - 2024-02-08

Expand Down
6 changes: 6 additions & 0 deletions ic-agent/src/agent/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,13 @@ pub struct Status {
impl std::fmt::Display for Status {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str("{\n")?;
let mut first = true;
for (key, value) in &self.values {
if first {
first = false;
} else {
f.write_str(",\n")?;
}
f.write_fmt(format_args!(r#" "{}": "#, key.escape_debug()))?;
std::fmt::Display::fmt(&value, f)?;
}
Expand Down