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

Absolutely bamboozled while trying to have pretty printed binary data as source code #281

Open
Speak2Erase opened this issue Jul 22, 2023 · 3 comments

Comments

@Speak2Erase
Copy link

I'm trying to use miette for my crate's error type. My crate parses binary data, and the errors can be quite difficult to understand, so I decided to pull miette in and see how it'd work.

miette's SourceCode impl for [u8] assumes it is string data, which means any users whose source is binary data need to write a custom impl. Atm, I'm stuck trying to figure out how to calculate where the SourceSpan offsets should go. Changing the offsets seems to move it completely- and higher offsets appear earlier in the text than they should?
I'm trying to pass in offsets into the original binary data, but they won't correspond exactly to the stringified version. Does that have something to do with it?

I have no idea what I'm doing, could I get some help?

@zkat
Copy link
Owner

zkat commented Jul 22, 2023

Yeah miette doesn't really support pretty-printed text very well--you can technically get things pointing at the right place, but that requires a lot of effort on your part. It's not a surprise you're having trouble with this, and I don't really have a solution for you right now. It's one of those backlog things that are fairly hard problems to solve.

@Speak2Erase
Copy link
Author

Ahh, alright. That makes sense

Is there anything I can do in the meantime then?

@zkat
Copy link
Owner

zkat commented Jul 23, 2023

You'll have to print stuff without syntax highlighting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants