bencode-pretty

Crates.iobencode-pretty
lib.rsbencode-pretty
version0.1.0
created_at2025-09-02 15:38:15.020539+00
updated_at2025-09-02 15:38:15.020539+00
descriptionA small program to pretty print data serialized in the bencode format.
homepage
repositoryhttps://github.com/P3KI/bendy
max_upload_size
id1821286
size27,765
Oliver Uvman (OliverUv)

documentation

README

pretty-bencode

Current Version License: BSD-3-Clause

A small CLI program to pretty print bencode. Just adds indentation and makes ascii-only byte strings print in a readable form. Built using the bendy crate.

Will only ingest valid bencode.

Installation

cargo install pretty-bencode

Usage

Can take a single bencode unit (list, dict, integer or byte string) from stdin.

echo "li1ei2ee" | pretty-bencode
l
    i1e
    i2e
e

Can take any number of bencode units, each from a different file.

pretty-bencode file1 file2 file3

Call with the --string-literal (-s) flag to print it formatted as a rust string literal.

echo "li1ei2ee" | pretty-bencode -s
let pretty_bencode = b"\
l\
        i1e\
        i2e\
e\
"

Byte String Representation

If bytestrings contain only bytes that are printable ASCII (bytes in range 40 <= b < 127) they will be printed as ascii characters. Otherwise they will be printed in hexadecimal. E.g. a byte string containing only one byte with the value zero will be printed as 1:\x00. The 1: is of course the standard bencode byte string length prefix.

Commit count: 271

cargo fmt