Add the Rust Debug format as an output format when decoding XDR #357
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
Add the Rust Debug format as an output format when decoding XDR.
Why
At times it's helpful to decode XDR into a format that ignores all formatting logic and just displays what's there in memory in the raw types. This is particularly useful because the JSON format the tool otherwise outputs makes several optimisations to the output so that it is human readable, but that makes it not possible to know exactly how in memory the data is represented when decoded.
For example, when decoding AssetCodes the JSON format hides what types of asset codes they are, favouring the human readable representations that for most developers do not need the distinction between AssetCode4 and AssetCode12:
Another example, when decoding source accounts the JSON format hides the significant structural differences between G and M accounts that again is not important to most developers:
But when debugging the exact data stored in the XDR, it is helpful to be able to look at these exact representations:
And also helpful with source accounts:
I needed to view this type of output for some XDR today while looking at fixing a bug in the XDR lib, and so I coded this to solve that problem and it seems reasonably useful to keep around.