summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@pep.foundation>2018-10-02 08:12:40 +0200
committerNeal H. Walfield <neal@pep.foundation>2018-10-02 08:12:40 +0200
commit1114a77ff28c1a6552b038262c2b090614bb0746 (patch)
tree12e00e789d3a3018b12560a0d83f6c29a4870b85
parent8087f38e2dca127b54bbf7b58533c712faa0cbfd (diff)
buffered-reader,openpgp: Simplify BufferedReaders' debugging output
- BufferedReaders are often nested. Print the current reader's state first and the inner reader last so that the debugging output is more readable.
-rw-r--r--buffered-reader/src/dup.rs2
-rw-r--r--openpgp/src/parse/hashed_reader.rs11
-rw-r--r--openpgp/src/parse/partial_body.rs2
3 files changed, 12 insertions, 3 deletions
diff --git a/buffered-reader/src/dup.rs b/buffered-reader/src/dup.rs
index ae9ce217..770a091f 100644
--- a/buffered-reader/src/dup.rs
+++ b/buffered-reader/src/dup.rs
@@ -23,8 +23,8 @@ pub struct BufferedReaderDup<'a, C> {
impl<'a, C> fmt::Debug for BufferedReaderDup<'a, C> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("BufferedReaderDup")
- .field("reader", &self.reader)
.field("cursor", &self.cursor)
+ .field("reader", &self.reader)
.finish()
}
}
diff --git a/openpgp/src/parse/hashed_reader.rs b/openpgp/src/parse/hashed_reader.rs
index 9bf2aac9..6b125230 100644
--- a/openpgp/src/parse/hashed_reader.rs
+++ b/openpgp/src/parse/hashed_reader.rs
@@ -1,6 +1,7 @@
use std::io;
use std::cmp;
use std::mem;
+use std::fmt;
use nettle::Hash;
@@ -14,12 +15,20 @@ use super::indent;
const TRACE : bool = false;
-#[derive(Debug)]
pub(crate) struct HashedReader<R: BufferedReader<Cookie>> {
reader: R,
cookie: Cookie,
}
+impl<R: BufferedReader<Cookie>> fmt::Debug for HashedReader<R> {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ f.debug_struct("HashedReader")
+ .field("cookie", &self.cookie)
+ .field("reader", &self.reader)
+ .finish()
+ }
+}
+
impl<R: BufferedReader<Cookie>> HashedReader<R> {
/// Instantiates a new hashed reader. `hashes_for` is the hash's
/// purpose. `algos` is a list of algorithms for which we should
diff --git a/openpgp/src/parse/partial_body.rs b/openpgp/src/parse/partial_body.rs
index 57c7a10a..a50cdc21 100644
--- a/openpgp/src/parse/partial_body.rs
+++ b/openpgp/src/parse/partial_body.rs
@@ -44,7 +44,6 @@ impl<T: BufferedReader<Cookie>> std::fmt::Debug
for BufferedReaderPartialBodyFilter<T> {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("BufferedReaderPartialBodyFilter")
- .field("reader", &self.reader)
.field("partial_body_length", &self.partial_body_length)
.field("last", &self.last)
.field("hash headers", &self.hash_headers)
@@ -54,6 +53,7 @@ impl<T: BufferedReader<Cookie>> std::fmt::Debug
} else {
None
})
+ .field("reader", &self.reader)
.finish()
}
}