Comments (5)
but I couldn't find an example of how to use this as a library.
Because, so far, nobody volunteered to write the documentation. Note that hexyl
was only recently turned into a library crate (#68). I never really designed it to be a library as well.
I imagine it should be pretty simple
Here you go:
Lines 1 to 20 in abc7939
but now I realize this can't be done since
Printer
doesn't allow you to specify a custom writer likeDisplay
expects.
Why not? Printer::new
takes a &'a mut Writer
with Writer: Write
(i.e. it takes a &mut impl Write
). When implementing Display::fmt
, you have access to a Formatter
, which itself implements Write
.
from hexyl.
Thank you for the update!
IIRC it was around the differences between
core::fmt::Write
andstd::io::Write
wherePrinter
takes a differentWriter
thanfmt::Display
expects.
Oh - you are right. Printer
takes a std::io::Write
. Formatter
implements std::fmt::Write
. I had never noticed that there are two versions of this.
If you come back to your project at some point and think that there is something that we can do here, please let us know.
from hexyl.
On a secondary note, I was hoping to use hexyl
as my Display
implementation, but now I realize this can't be done since Printer
doesn't allow you to specify a custom writer like Display
expects.
from hexyl.
Some kind of reaction/response would have been nice :-/
from hexyl.
Hi @sharkdp, I'm really sorry for not having gotten back to you, this escaped me in the GH notification chaos.
Thanks a lot for adding the lib usage example! Regarding the issues with implementing Display
, I haven't touched the project I was working on in a while, but IIRC it was around the differences between core::fmt::Write
and std::io::Write
where Printer
takes a different Writer
than fmt::Display
expects. You can write an adapter, but it's ugly.
c.f. https://github.com/lovesegfault/chirp/blob/master/src/memory.rs#L31-L43
from hexyl.
Related Issues (20)
- Is there a cheat sheet anywhere telling what color correlates to category of byte? HOT 3
- Add support for the NO_COLOR environment variable HOT 4
- Regression: broken pipe error
- Make --panels=auto the new default? HOT 3
- hexyl should not fail if `--panels=auto` is used and output is not a TTY
- Identical lines not squeezed HOT 3
- hexyl -C does the inverse of hexdump -C HOT 1
- Request: publish source tar with generated manpage HOT 3
- Support for different code pages / character tables
- Incorrect output when reading from terminal HOT 2
- Feature request: Ship as a crate HOT 3
- `hexyl /dev/zero` hangs HOT 6
- Display some non-printable characters like `bat --show-all` HOT 5
- Feature request: Comodore prg mode HOT 1
- CI artifact names conflict HOT 2
- Provide Statically Compiled Binaries for (aarch64|arm64) Linux HOT 1
- Support raw output HOT 2
- Customize colors
- Completions for fish shell HOT 1
- is there a way to open disk devices in windows? HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hexyl.