From 6a2a82648176e4b840bfed80e188c21b6bc63c4d Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Tue, 24 Mar 2020 12:46:30 +0100 Subject: openpgp: Add convenience function hex::dump. --- openpgp/src/fmt.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/openpgp/src/fmt.rs b/openpgp/src/fmt.rs index 3b79ceba..afe98bb6 100644 --- a/openpgp/src/fmt.rs +++ b/openpgp/src/fmt.rs @@ -27,6 +27,12 @@ pub mod hex { super::from_hex(hex.as_ref(), true) } + /// Dumps binary data, like `hd(1)`. + pub fn dump>(sink: W, data: B) + -> io::Result<()> { + Dumper::new(sink, "").write_ascii(data) + } + /// Writes annotated hex dumps, like hd(1). /// /// # Example @@ -91,7 +97,7 @@ pub mod hex { /// Writes a chunk of data with ASCII-representation. /// - /// This produces output similar to `hexdump(1)`. + /// This produces output similar to `hd(1)`. pub fn write_ascii(&mut self, buf: B) -> io::Result<()> where B: AsRef<[u8]>, { -- cgit v1.2.3