decoder: add Frame::fragments() and Frame::display_fragments() #966
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.
One cool possibility with defmt is a log viewer that can do more than just display static text, eg. change number representations on the fly. These two methods should make doing something like that a bit easier.
Copying from the docs I put on
display_fragments()
:Returns an iterator over the fragments of the message contained in this log frame.
Collecting this into a String will yield the same result as
Self::display_message
, butthis iterator will yield interpolated fragments on their own. For example, the log:
Will yield the following strings:
Note that nested fragments will not yield separately:
Will yield:
This iterator yields the same fragments as
Self::fragments
, so you can zip themtogether to get both representations.
This is quite limited in that it doesn't go into nested fragments, but could already enable some limited extra functionality with minimal effort.
Haven't tested on an actual project yet, intend to do that tomorrow.