diff options
Diffstat (limited to 'buffered-reader')
-rw-r--r-- | buffered-reader/src/decompress_bzip2.rs | 8 | ||||
-rw-r--r-- | buffered-reader/src/decompress_deflate.rs | 16 | ||||
-rw-r--r-- | buffered-reader/src/dup.rs | 7 | ||||
-rw-r--r-- | buffered-reader/src/eof.rs | 6 | ||||
-rw-r--r-- | buffered-reader/src/file_generic.rs | 6 | ||||
-rw-r--r-- | buffered-reader/src/file_unix.rs | 17 | ||||
-rw-r--r-- | buffered-reader/src/generic.rs | 6 | ||||
-rw-r--r-- | buffered-reader/src/lib.rs | 2 | ||||
-rw-r--r-- | buffered-reader/src/limitor.rs | 6 | ||||
-rw-r--r-- | buffered-reader/src/memory.rs | 7 | ||||
-rw-r--r-- | buffered-reader/src/reserve.rs | 6 |
11 files changed, 83 insertions, 4 deletions
diff --git a/buffered-reader/src/decompress_bzip2.rs b/buffered-reader/src/decompress_bzip2.rs index f118fa6a..4224f686 100644 --- a/buffered-reader/src/decompress_bzip2.rs +++ b/buffered-reader/src/decompress_bzip2.rs @@ -40,7 +40,7 @@ impl<R: BufferedReader<C>, C> io::Read for BufferedReaderBzip<R, C> { } } -impl <R: BufferedReader<C>, C> fmt::Debug for BufferedReaderBzip<R, C> { +impl<R: BufferedReader<C>, C> fmt::Debug for BufferedReaderBzip<R, C> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("BufferedReaderBzip") .field("reader", &self.get_ref().unwrap()) @@ -48,6 +48,12 @@ impl <R: BufferedReader<C>, C> fmt::Debug for BufferedReaderBzip<R, C> { } } +impl<R: BufferedReader<C>, C> fmt::Display for BufferedReaderBzip<R, C> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "BufferedReaderBzip") + } +} + impl<R: BufferedReader<C>, C> BufferedReader<C> for BufferedReaderBzip<R, C> { fn buffer(&self) -> &[u8] { return self.reader.buffer(); diff --git a/buffered-reader/src/decompress_deflate.rs b/buffered-reader/src/decompress_deflate.rs index 3f3da76c..42633419 100644 --- a/buffered-reader/src/decompress_deflate.rs +++ b/buffered-reader/src/decompress_deflate.rs @@ -40,7 +40,13 @@ impl<R: BufferedReader<C>, C> io::Read for BufferedReaderDeflate<R, C> { } } -impl <R: BufferedReader<C>, C> fmt::Debug for BufferedReaderDeflate<R, C> { +impl<R: BufferedReader<C>, C> fmt::Display for BufferedReaderDeflate<R, C> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "BufferedReaderDeflate") + } +} + +impl<R: BufferedReader<C>, C> fmt::Debug for BufferedReaderDeflate<R, C> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("BufferedReaderDeflate") .field("reader", &self.get_ref().unwrap()) @@ -156,7 +162,13 @@ impl<R: BufferedReader<C>, C> io::Read for BufferedReaderZlib<R, C> { } } -impl <R: BufferedReader<C>, C> fmt::Debug for BufferedReaderZlib<R, C> { +impl<R: BufferedReader<C>, C> fmt::Display for BufferedReaderZlib<R, C> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "BufferedReaderZlib") + } +} + +impl<R: BufferedReader<C>, C> fmt::Debug for BufferedReaderZlib<R, C> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("BufferedReaderZlib") .field("reader", &self.get_ref().unwrap()) diff --git a/buffered-reader/src/dup.rs b/buffered-reader/src/dup.rs index 4dd8c347..123e13d6 100644 --- a/buffered-reader/src/dup.rs +++ b/buffered-reader/src/dup.rs @@ -20,6 +20,13 @@ pub struct BufferedReaderDup<'a, C> { cookie: C, } +impl<'a, C> fmt::Display for BufferedReaderDup<'a, C> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "BufferedReaderDup ({} bytes consumed)", + self.cursor) + } +} + impl<'a, C> fmt::Debug for BufferedReaderDup<'a, C> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("BufferedReaderDup") diff --git a/buffered-reader/src/eof.rs b/buffered-reader/src/eof.rs index cadc035a..424e2245 100644 --- a/buffered-reader/src/eof.rs +++ b/buffered-reader/src/eof.rs @@ -9,6 +9,12 @@ pub struct BufferedReaderEOF<C> { cookie: C, } +impl<C> fmt::Display for BufferedReaderEOF<C> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "BufferedReaderEOF") + } +} + impl<C> fmt::Debug for BufferedReaderEOF<C> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("BufferedReaderEOF") diff --git a/buffered-reader/src/file_generic.rs b/buffered-reader/src/file_generic.rs index 45844a78..c0cc489d 100644 --- a/buffered-reader/src/file_generic.rs +++ b/buffered-reader/src/file_generic.rs @@ -11,6 +11,12 @@ use super::*; /// platform-specific versions. pub struct BufferedReaderFile<C>(BufferedReaderGeneric<File, C>); +impl<C> fmt::Display for BufferedReaderFile<C> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "BufferedReaderFile") + } +} + impl<C> fmt::Debug for BufferedReaderFile<C> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_tuple("BufferedReaderFile") diff --git a/buffered-reader/src/file_unix.rs b/buffered-reader/src/file_unix.rs index 9dc80ce1..bb6f2673 100644 --- a/buffered-reader/src/file_unix.rs +++ b/buffered-reader/src/file_unix.rs @@ -26,6 +26,12 @@ const MMAP_THRESHOLD: u64 = 16 * 4096; /// just using a generic reader. pub struct BufferedReaderFile<'a, C>(Imp<'a, C>); +impl<'a, C> fmt::Display for BufferedReaderFile<'a, C> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", self.0) + } +} + impl<'a, C> fmt::Debug for BufferedReaderFile<'a, C> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_tuple("BufferedReaderFile") @@ -56,6 +62,17 @@ impl<'a, C> Drop for Imp<'a, C> { } } +impl<'a, C> fmt::Display for Imp<'a, C> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "BufferedReaderFile(")?; + match self { + Imp::Generic(_) => write!(f, "BufferedReaderGeneric")?, + Imp::MMAP { .. } => write!(f, "BufferedReaderMemory")?, + }; + write!(f, ")") + } +} + impl<'a, C> fmt::Debug for Imp<'a, C> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { diff --git a/buffered-reader/src/generic.rs b/buffered-reader/src/generic.rs index a2a5321b..882c64e9 100644 --- a/buffered-reader/src/generic.rs +++ b/buffered-reader/src/generic.rs @@ -27,6 +27,12 @@ pub struct BufferedReaderGeneric<T: io::Read, C> { cookie: C, } +impl<T: io::Read, C> fmt::Display for BufferedReaderGeneric<T, C> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "BufferedReaderGeneric") + } +} + impl<T: io::Read, C> fmt::Debug for BufferedReaderGeneric<T, C> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let buffered_data = if let Some(ref buffer) = self.buffer { diff --git a/buffered-reader/src/lib.rs b/buffered-reader/src/lib.rs index d8f9eadc..f56e188c 100644 --- a/buffered-reader/src/lib.rs +++ b/buffered-reader/src/lib.rs @@ -276,7 +276,7 @@ pub use self::file_unix::BufferedReaderFile; const DEFAULT_BUF_SIZE: usize = 8 * 1024; /// The generic `BufferReader` interface. -pub trait BufferedReader<C> : io::Read + fmt::Debug { +pub trait BufferedReader<C> : io::Read + fmt::Debug + fmt::Display { /// Returns a reference to the internal buffer. /// /// Note: this returns the same data as `self.data(0)`, but it diff --git a/buffered-reader/src/limitor.rs b/buffered-reader/src/limitor.rs index a132aefe..e53ca202 100644 --- a/buffered-reader/src/limitor.rs +++ b/buffered-reader/src/limitor.rs @@ -12,6 +12,12 @@ pub struct BufferedReaderLimitor<'a, C> { cookie: C, } +impl<'a, C> fmt::Display for BufferedReaderLimitor<'a, C> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "BufferedReaderLimitor ({} bytes)", self.limit) + } +} + impl<'a, C> fmt::Debug for BufferedReaderLimitor<'a, C> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("BufferedReaderLimitor") diff --git a/buffered-reader/src/memory.rs b/buffered-reader/src/memory.rs index a7e8c1de..fc94f8fb 100644 --- a/buffered-reader/src/memory.rs +++ b/buffered-reader/src/memory.rs @@ -20,6 +20,13 @@ pub struct BufferedReaderMemory<'a, C> { cookie: C, } +impl<'a, C> fmt::Display for BufferedReaderMemory<'a, C> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "BufferedReaderMemory ({} of {} bytes read)", + self.cursor, self.buffer.len()) + } +} + impl<'a, C> fmt::Debug for BufferedReaderMemory<'a, C> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("BufferedReaderMemory") diff --git a/buffered-reader/src/reserve.rs b/buffered-reader/src/reserve.rs index 24927913..717c29ac 100644 --- a/buffered-reader/src/reserve.rs +++ b/buffered-reader/src/reserve.rs @@ -16,6 +16,12 @@ pub struct BufferedReaderReserve<'a, C> { cookie: C, } +impl<'a, C> fmt::Display for BufferedReaderReserve<'a, C> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "BufferedReaderReserve ({} bytes)", self.reserve) + } +} + impl<'a, C> fmt::Debug for BufferedReaderReserve<'a, C> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("BufferedReaderReserve") |