Closed elsirion closed 4 days ago
@dpc this project might be unmaintained, should we just publish a fork?
@elsirion Rust Bitcoin has a separate hex crate now or something. Maybe we can just add it there. Maintaining creates is a lot of ungrateful work. 🤣
HexWriter
allows to directly hex-encode binary data to astd::fmt::Write
object from any source that can write to astd::io::Write
object. This saves between one and two allocations depending on the use case.Let's assume a function
Foo::encode(&self, writer: std::io::Write) -> Result<(), std::io::Error>
:Foo
object toFormatter
as hex would require 2 allocations: one to encode bytes into aVec<u8>
and a second to encode the bytes into aString
before writing it to theFormatter
. Here we can save 2 allocations.Foo
struct as hex into aString
, here we only save 1 allocation (the intermediate byte step)Vec<u8>
as hex to aFormatter
: 1 allocation saved (String
)