#hex #viewer #compiler #file

应用 rustc-hex-viewer

使用Rust编译器作为十六进制查看器

1 个稳定版本

1.0.0 2022年8月25日

编程语言中排名第521

GPL-3.0 许可协议

4KB

rustc-hex-viewer

你知道吗,Rust编译器有一个内置的十六进制查看器吗?

这个crate实现了一个简单的接口来访问这个功能,只需用想要读取的文件编译它,并将其放在FILE环境变量中即可

git clone https://github.com/Badel2/rustc-hex-viewer
cd rustc-hex-viewer
FILE=/etc/passwd cargo build

或者,如果您喜欢一行命令

FILE=/etc/passwd cargo install --git https://github.com/Badel2/rustc-hex-viewer

示例输出

$ FILE=<(head -c 31 /dev/urandom) cargo build
   Compiling rustc-hex-viewer v0.1.0 (/home/bdl/projects/rustc-hex-viewer)
error[E0080]: it is undefined behavior to use this value
  --> src/lib.rs:21:1
   |
21 | const RUSTC: HEX = VIEWER();
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .1[31]: encountered uninitialized bytes
   |
   = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
   = note: the raw bytes of the constant (size: 32, align: 1) {
               0x00 │ 90 5a 59 34 62 5d 3a e9 15 95 74 cf c4 4e 3b 08 │ .ZY4b]:...t..N;.
               0x10 │ c7 e3 41 83 57 b6 eb 92 40 39 d8 61 a0 9b 07 __ │ [email protected]...░
           }

For more information about this error, try `rustc --explain E0080`.
error: could not compile `rustc-hex-viewer` due to previous error

没有运行时依赖