diff options
Diffstat (limited to 'buffered-reader')
-rw-r--r-- | buffered-reader/src/adapter.rs | 12 | ||||
-rw-r--r-- | buffered-reader/src/decompress_bzip2.rs | 10 | ||||
-rw-r--r-- | buffered-reader/src/decompress_deflate.rs | 22 | ||||
-rw-r--r-- | buffered-reader/src/dup.rs | 10 | ||||
-rw-r--r-- | buffered-reader/src/eof.rs | 2 | ||||
-rw-r--r-- | buffered-reader/src/file_generic.rs | 12 | ||||
-rw-r--r-- | buffered-reader/src/file_unix.rs | 20 | ||||
-rw-r--r-- | buffered-reader/src/generic.rs | 14 | ||||
-rw-r--r-- | buffered-reader/src/lib.rs | 12 | ||||
-rw-r--r-- | buffered-reader/src/limitor.rs | 10 | ||||
-rw-r--r-- | buffered-reader/src/memory.rs | 10 | ||||
-rw-r--r-- | buffered-reader/src/reserve.rs | 12 |
12 files changed, 73 insertions, 73 deletions
diff --git a/buffered-reader/src/adapter.rs b/buffered-reader/src/adapter.rs index 65c7a8aa..3734d9bc 100644 --- a/buffered-reader/src/adapter.rs +++ b/buffered-reader/src/adapter.rs @@ -10,7 +10,7 @@ use super::*; /// `Adapter` also changes cookie types, but does no buffering of its /// own. #[derive(Debug)] -pub struct Adapter<T: BufferedReader<B>, B: fmt::Debug, C: fmt::Debug> { +pub struct Adapter<T: BufferedReader<B>, B: fmt::Debug + Send + Sync, C: fmt::Debug + Sync + Send> { reader: T, _ghostly_cookie: std::marker::PhantomData<B>, cookie: C, @@ -21,13 +21,13 @@ assert_send_and_sync!(Adapter<T, B, C> B: fmt::Debug, C: fmt::Debug); -impl<T: BufferedReader<B>, B: fmt::Debug, C: fmt::Debug> fmt::Display for Adapter<T, B, C> { +impl<T: BufferedReader<B>, B: fmt::Debug + Send + Sync, C: fmt::Debug + Sync + Send> fmt::Display for Adapter<T, B, C> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("Adapter").finish() } } -impl<T: BufferedReader<B>, B: fmt::Debug> Adapter<T, B, ()> { +impl<T: BufferedReader<B>, B: fmt::Debug + Sync + Send> Adapter<T, B, ()> { /// Instantiates a new adapter. /// /// `reader` is the source to wrap. @@ -36,7 +36,7 @@ impl<T: BufferedReader<B>, B: fmt::Debug> Adapter<T, B, ()> { } } -impl<T: BufferedReader<B>, B: fmt::Debug, C: fmt::Debug> Adapter<T, B, C> { +impl<T: BufferedReader<B>, B: fmt::Debug + Send + Sync, C: fmt::Debug + Sync + Send> Adapter<T, B, C> { /// Like `new()`, but sets a cookie. /// /// The cookie can be retrieved using the `cookie_ref` and @@ -51,13 +51,13 @@ impl<T: BufferedReader<B>, B: fmt::Debug, C: fmt::Debug> Adapter<T, B, C> { } } -impl<T: BufferedReader<B>, B: fmt::Debug, C: fmt::Debug> io::Read for Adapter<T, B, C> { +impl<T: BufferedReader<B>, B: fmt::Debug + Send + Sync, C: fmt::Debug + Sync + Send> io::Read for Adapter<T, B, C> { fn read(&mut self, buf: &mut [u8]) -> Result<usize, io::Error> { self.reader.read(buf) } } -impl<T: BufferedReader<B>, B: fmt::Debug, C: fmt::Debug> BufferedReader<C> for Adapter<T, B, C> { +impl<T: BufferedReader<B>, B: fmt::Debug + Send + Sync, C: fmt::Debug + Sync + Send> BufferedReader<C> for Adapter<T, B, C> { fn buffer(&self) -> &[u8] { self.reader.buffer() } diff --git a/buffered-reader/src/decompress_bzip2.rs b/buffered-reader/src/decompress_bzip2.rs index 8902c2af..febe37fc 100644 --- a/buffered-reader/src/decompress_bzip2.rs +++ b/buffered-reader/src/decompress_bzip2.rs @@ -9,7 +9,7 @@ use super::*; /// Decompresses the underlying `BufferedReader` using the bzip2 /// algorithm. #[derive(Debug)] -pub struct Bzip<R: BufferedReader<C>, C: fmt::Debug> { +pub struct Bzip<R: BufferedReader<C>, C: fmt::Debug + Sync + Send> { reader: Generic<BzDecoder<R>, C>, } @@ -26,7 +26,7 @@ impl <R: BufferedReader<()>> Bzip<R, ()> { } } -impl <R: BufferedReader<C>, C: fmt::Debug> Bzip<R, C> { +impl <R: BufferedReader<C>, C: fmt::Debug + Sync + Send> Bzip<R, C> { /// Like `new()`, but uses a cookie. /// /// The cookie can be retrieved using the `cookie_ref` and @@ -39,19 +39,19 @@ impl <R: BufferedReader<C>, C: fmt::Debug> Bzip<R, C> { } } -impl<R: BufferedReader<C>, C: fmt::Debug> io::Read for Bzip<R, C> { +impl<R: BufferedReader<C>, C: fmt::Debug + Sync + Send> io::Read for Bzip<R, C> { fn read(&mut self, buf: &mut [u8]) -> Result<usize, io::Error> { self.reader.read(buf) } } -impl<R: BufferedReader<C>, C: fmt::Debug> fmt::Display for Bzip<R, C> { +impl<R: BufferedReader<C>, C: fmt::Debug + Sync + Send> fmt::Display for Bzip<R, C> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("Bzip").finish() } } -impl<R: BufferedReader<C>, C: fmt::Debug> BufferedReader<C> for Bzip<R, C> { +impl<R: BufferedReader<C>, C: fmt::Debug + Send + Sync> BufferedReader<C> for Bzip<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 43084a5f..d1d1a16b 100644 --- a/buffered-reader/src/decompress_deflate.rs +++ b/buffered-reader/src/decompress_deflate.rs @@ -9,7 +9,7 @@ use super::*; /// Decompresses the underlying `BufferedReader` using the deflate /// algorithm. #[derive(Debug)] -pub struct Deflate<R: BufferedReader<C>, C: fmt::Debug> { +pub struct Deflate<R: BufferedReader<C>, C: fmt::Debug + Sync + Send> { reader: Generic<DeflateDecoder<R>, C>, } @@ -26,7 +26,7 @@ impl <R: BufferedReader<()>> Deflate<R, ()> { } } -impl <R: BufferedReader<C>, C: fmt::Debug> Deflate<R, C> { +impl <R: BufferedReader<C>, C: fmt::Debug + Sync + Send> Deflate<R, C> { /// Like `new()`, but uses a cookie. /// /// The cookie can be retrieved using the `cookie_ref` and @@ -39,19 +39,19 @@ impl <R: BufferedReader<C>, C: fmt::Debug> Deflate<R, C> { } } -impl<R: BufferedReader<C>, C: fmt::Debug> io::Read for Deflate<R, C> { +impl<R: BufferedReader<C>, C: fmt::Debug + Sync + Send> io::Read for Deflate<R, C> { fn read(&mut self, buf: &mut [u8]) -> Result<usize, io::Error> { self.reader.read(buf) } } -impl<R: BufferedReader<C>, C: fmt::Debug> fmt::Display for Deflate<R, C> { +impl<R: BufferedReader<C>, C: fmt::Debug + Sync + Send> fmt::Display for Deflate<R, C> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("Deflate").finish() } } -impl<R: BufferedReader<C>, C: fmt::Debug> BufferedReader<C> +impl<R: BufferedReader<C>, C: fmt::Debug + Send + Sync> BufferedReader<C> for Deflate<R, C> { fn buffer(&self) -> &[u8] { return self.reader.buffer(); @@ -127,7 +127,7 @@ impl<R: BufferedReader<C>, C: fmt::Debug> BufferedReader<C> /// Decompresses the underlying `BufferedReader` using the zlib /// algorithm. -pub struct Zlib<R: BufferedReader<C>, C: fmt::Debug> { +pub struct Zlib<R: BufferedReader<C>, C: fmt::Debug + Sync + Send> { reader: Generic<ZlibDecoder<R>, C>, } @@ -144,7 +144,7 @@ impl <R: BufferedReader<()>> Zlib<R, ()> { } } -impl <R: BufferedReader<C>, C: fmt::Debug> Zlib<R, C> { +impl <R: BufferedReader<C>, C: fmt::Debug + Sync + Send> Zlib<R, C> { /// Like `new()`, but uses a cookie. /// /// The cookie can be retrieved using the `cookie_ref` and @@ -157,19 +157,19 @@ impl <R: BufferedReader<C>, C: fmt::Debug> Zlib<R, C> { } } -impl<R: BufferedReader<C>, C: fmt::Debug> io::Read for Zlib<R, C> { +impl<R: BufferedReader<C>, C: fmt::Debug + Sync + Send> io::Read for Zlib<R, C> { fn read(&mut self, buf: &mut [u8]) -> Result<usize, io::Error> { self.reader.read(buf) } } -impl<R: BufferedReader<C>, C: fmt::Debug> fmt::Display for Zlib<R, C> { +impl<R: BufferedReader<C>, C: fmt::Debug + Sync + Send> fmt::Display for Zlib<R, C> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "Zlib") } } -impl<R: BufferedReader<C>, C: fmt::Debug> fmt::Debug for Zlib<R, C> { +impl<R: BufferedReader<C>, C: fmt::Debug + Sync + Send> fmt::Debug for Zlib<R, C> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("Zlib") .field("reader", &self.get_ref().unwrap()) @@ -177,7 +177,7 @@ impl<R: BufferedReader<C>, C: fmt::Debug> fmt::Debug for Zlib<R, C> { } } -impl<R: BufferedReader<C>, C: fmt::Debug> BufferedReader<C> +impl<R: BufferedReader<C>, C: fmt::Debug + Send + Sync> BufferedReader<C> for Zlib<R, C> { fn buffer(&self) -> &[u8] { return self.reader.buffer(); diff --git a/buffered-reader/src/dup.rs b/buffered-reader/src/dup.rs index 50a9aa26..d7d3f7e5 100644 --- a/buffered-reader/src/dup.rs +++ b/buffered-reader/src/dup.rs @@ -11,7 +11,7 @@ use super::*; /// much data as you read. Thus, it should only be used for peeking /// at the underlying `BufferedReader`. #[derive(Debug)] -pub struct Dup<T: BufferedReader<C>, C: fmt::Debug> { +pub struct Dup<T: BufferedReader<C>, C: fmt::Debug + Sync + Send> { reader: T, // The number of bytes that have been consumed. @@ -25,7 +25,7 @@ assert_send_and_sync!(Dup<T, C> where T: BufferedReader<C>, C: fmt::Debug); -impl<T: BufferedReader<C>, C: fmt::Debug> fmt::Display for Dup<T, C> { +impl<T: BufferedReader<C>, C: fmt::Debug + Sync + Send> fmt::Display for Dup<T, C> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("Dup") .field("cursor", &self.cursor) @@ -42,7 +42,7 @@ impl<T: BufferedReader<()>> Dup<T, ()> { } } -impl<T: BufferedReader<C>, C: fmt::Debug> Dup<T, C> { +impl<T: BufferedReader<C>, C: fmt::Debug + Sync + Send> Dup<T, C> { /// Like `new()`, but uses a cookie. /// /// The cookie can be retrieved using the `cookie_ref` and @@ -66,7 +66,7 @@ impl<T: BufferedReader<C>, C: fmt::Debug> Dup<T, C> { } } -impl<T: BufferedReader<C>, C: fmt::Debug> io::Read for Dup<T, C> { +impl<T: BufferedReader<C>, C: fmt::Debug + Sync + Send> io::Read for Dup<T, C> { fn read(&mut self, buf: &mut [u8]) -> Result<usize, io::Error> { let data = self.reader.data(self.cursor + buf.len())?; assert!(data.len() >= self.cursor); @@ -81,7 +81,7 @@ impl<T: BufferedReader<C>, C: fmt::Debug> io::Read for Dup<T, C> { } } -impl<T: BufferedReader<C>, C: fmt::Debug> BufferedReader<C> for Dup<T, C> { +impl<T: BufferedReader<C>, C: fmt::Debug + Send + Sync> BufferedReader<C> for Dup<T, C> { fn buffer(&self) -> &[u8] { let data = self.reader.buffer(); assert!(data.len() >= self.cursor); diff --git a/buffered-reader/src/eof.rs b/buffered-reader/src/eof.rs index c21ecde9..b0312630 100644 --- a/buffered-reader/src/eof.rs +++ b/buffered-reader/src/eof.rs @@ -44,7 +44,7 @@ impl<C> Read for EOF<C> { } } -impl<C: fmt::Debug> BufferedReader<C> for EOF<C> { +impl<C: fmt::Debug + Sync + Send> BufferedReader<C> for EOF<C> { fn buffer(&self) -> &[u8] { return &b""[..]; } diff --git a/buffered-reader/src/file_generic.rs b/buffered-reader/src/file_generic.rs index cc9f1367..2c61e571 100644 --- a/buffered-reader/src/file_generic.rs +++ b/buffered-reader/src/file_generic.rs @@ -10,18 +10,18 @@ use crate::file_error::FileError; /// /// This is a generic implementation that may be replaced by /// platform-specific versions. -pub struct File<C: fmt::Debug>(Generic<fs::File, C>, PathBuf); +pub struct File<C: fmt::Debug + Sync + Send>(Generic<fs::File, C>, PathBuf); assert_send_and_sync!(File<C> where C: fmt::Debug); -impl<C: fmt::Debug> fmt::Display for File<C> { +impl<C: fmt::Debug + Sync + Send> fmt::Display for File<C> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "File {:?}", self.1.display()) } } -impl<C: fmt::Debug> fmt::Debug for File<C> { +impl<C: fmt::Debug + Sync + Send> fmt::Debug for File<C> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_tuple("File") .field(&self.0) @@ -37,7 +37,7 @@ impl File<()> { } } -impl<C: fmt::Debug> File<C> { +impl<C: fmt::Debug + Sync + Send> File<C> { /// Like `open()`, but sets a cookie. pub fn with_cookie<P: AsRef<Path>>(path: P, cookie: C) -> io::Result<Self> { let path = path.as_ref(); @@ -46,14 +46,14 @@ impl<C: fmt::Debug> File<C> { } } -impl<C: fmt::Debug> io::Read for File<C> { +impl<C: fmt::Debug + Sync + Send> io::Read for File<C> { fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> { self.0.read(buf) .map_err(|e| FileError::new(&self.1, e)) } } -impl<C: fmt::Debug> BufferedReader<C> for File<C> { +impl<C: fmt::Debug + Sync + Send> BufferedReader<C> for File<C> { fn buffer(&self) -> &[u8] { self.0.buffer() } diff --git a/buffered-reader/src/file_unix.rs b/buffered-reader/src/file_unix.rs index 9502021f..a1298737 100644 --- a/buffered-reader/src/file_unix.rs +++ b/buffered-reader/src/file_unix.rs @@ -25,18 +25,18 @@ const MMAP_THRESHOLD: u64 = 16 * 4096; /// /// This implementation tries to mmap the file, falling back to /// just using a generic reader. -pub struct File<'a, C: fmt::Debug>(Imp<'a, C>, PathBuf); +pub struct File<'a, C: fmt::Debug + Sync + Send>(Imp<'a, C>, PathBuf); assert_send_and_sync!(File<'_, C> where C: fmt::Debug); -impl<'a, C: fmt::Debug> fmt::Display for File<'a, C> { +impl<'a, C: fmt::Debug + Sync + Send> fmt::Display for File<'a, C> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{} {:?}", self.0, self.1.display()) } } -impl<'a, C: fmt::Debug> fmt::Debug for File<'a, C> { +impl<'a, C: fmt::Debug + Sync + Send> fmt::Debug for File<'a, C> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_tuple("File") .field(&self.0) @@ -46,14 +46,14 @@ impl<'a, C: fmt::Debug> fmt::Debug for File<'a, C> { } /// The implementation. -enum Imp<'a, C: fmt::Debug> { +enum Imp<'a, C: fmt::Debug + Sync + Send> { Generic(Generic<fs::File, C>), MMAP { reader: Memory<'a, C>, } } -impl<'a, C: fmt::Debug> Drop for Imp<'a, C> { +impl<'a, C: fmt::Debug + Sync + Send> Drop for Imp<'a, C> { fn drop(&mut self) { match self { Imp::Generic(_) => (), @@ -67,7 +67,7 @@ impl<'a, C: fmt::Debug> Drop for Imp<'a, C> { } } -impl<'a, C: fmt::Debug> fmt::Display for Imp<'a, C> { +impl<'a, C: fmt::Debug + Sync + Send> fmt::Display for Imp<'a, C> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "File(")?; match self { @@ -78,7 +78,7 @@ impl<'a, C: fmt::Debug> fmt::Display for Imp<'a, C> { } } -impl<'a, C: fmt::Debug> fmt::Debug for Imp<'a, C> { +impl<'a, C: fmt::Debug + Sync + Send> fmt::Debug for Imp<'a, C> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { Imp::Generic(ref g) => @@ -102,7 +102,7 @@ impl<'a> File<'a, ()> { } } -impl<'a, C: fmt::Debug> File<'a, C> { +impl<'a, C: fmt::Debug + Sync + Send> File<'a, C> { /// Like `open()`, but sets a cookie. pub fn with_cookie<P: AsRef<Path>>(path: P, cookie: C) -> io::Result<Self> { let path = path.as_ref(); @@ -160,7 +160,7 @@ impl<'a, C: fmt::Debug> File<'a, C> { } } -impl<'a, C: fmt::Debug> io::Read for File<'a, C> { +impl<'a, C: fmt::Debug + Sync + Send> io::Read for File<'a, C> { fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> { match self.0 { Imp::Generic(ref mut reader) => reader.read(buf), @@ -169,7 +169,7 @@ impl<'a, C: fmt::Debug> io::Read for File<'a, C> { } } -impl<'a, C: fmt::Debug> BufferedReader<C> for File<'a, C> { +impl<'a, C: fmt::Debug + Sync + Send> BufferedReader<C> for File<'a, C> { fn buffer(&self) -> &[u8] { match self.0 { Imp::Generic(ref reader) => reader.buffer(), diff --git a/buffered-reader/src/generic.rs b/buffered-reader/src/generic.rs index 25c56272..d2e9acfa 100644 --- a/buffered-reader/src/generic.rs +++ b/buffered-reader/src/generic.rs @@ -13,7 +13,7 @@ use super::*; /// /// [`File`]: struct.File.html /// [`Memory`]: struct.Memory.html -pub struct Generic<T: io::Read, C: fmt::Debug> { +pub struct Generic<T: io::Read + Send + Sync, C: fmt::Debug + Sync + Send> { buffer: Option<Box<[u8]>>, // The next byte to read in the buffer. cursor: usize, @@ -32,13 +32,13 @@ assert_send_and_sync!(Generic<T, C> where T: io::Read, C: fmt::Debug); -impl<T: io::Read, C: fmt::Debug> fmt::Display for Generic<T, C> { +impl<T: io::Read + Send + Sync, C: fmt::Debug + Sync + Send> fmt::Display for Generic<T, C> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "Generic") } } -impl<T: io::Read, C: fmt::Debug> fmt::Debug for Generic<T, C> { +impl<T: io::Read + Send + Sync, C: fmt::Debug + Sync + Send> fmt::Debug for Generic<T, C> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let buffered_data = if let Some(ref buffer) = self.buffer { buffer.len() - self.cursor @@ -53,7 +53,7 @@ impl<T: io::Read, C: fmt::Debug> fmt::Debug for Generic<T, C> { } } -impl<T: io::Read> Generic<T, ()> { +impl<T: io::Read + Send + Sync> Generic<T, ()> { /// Instantiate a new generic reader. `reader` is the source to /// wrap. `preferred_chuck_size` is the preferred chuck size. If /// None, then the default will be used, which is usually what you @@ -63,7 +63,7 @@ impl<T: io::Read> Generic<T, ()> { } } -impl<T: io::Read, C: fmt::Debug> Generic<T, C> { +impl<T: io::Read + Send + Sync, C: fmt::Debug + Sync + Send> Generic<T, C> { /// Like `new()`, but sets a cookie, which can be retrieved using /// the `cookie_ref` and `cookie_mut` methods, and set using /// the `cookie_set` method. @@ -206,13 +206,13 @@ impl<T: io::Read, C: fmt::Debug> Generic<T, C> { } } -impl<T: io::Read, C: fmt::Debug> io::Read for Generic<T, C> { +impl<T: io::Read + Send + Sync, C: fmt::Debug + Sync + Send> io::Read for Generic<T, C> { fn read(&mut self, buf: &mut [u8]) -> Result<usize, io::Error> { return buffered_reader_generic_read_impl(self, buf); } } -impl<T: io::Read, C: fmt::Debug> BufferedReader<C> for Generic<T, C> { +impl<T: io::Read + Send + Sync, C: fmt::Debug + Sync + Send> BufferedReader<C> for Generic<T, C> { fn buffer(&self) -> &[u8] { if let Some(ref buffer) = self.buffer { &buffer[self.cursor..] diff --git a/buffered-reader/src/lib.rs b/buffered-reader/src/lib.rs index 45c12726..f146741d 100644 --- a/buffered-reader/src/lib.rs +++ b/buffered-reader/src/lib.rs @@ -300,8 +300,8 @@ fn vec_truncate(v: &mut Vec<u8>, len: usize) { } /// The generic `BufferReader` interface. -pub trait BufferedReader<C> : io::Read + fmt::Debug + fmt::Display - where C: fmt::Debug +pub trait BufferedReader<C> : io::Read + fmt::Debug + fmt::Display + Send + Sync + where C: fmt::Debug + Send + Sync { /// Returns a reference to the internal buffer. /// @@ -907,7 +907,7 @@ pub trait BufferedReader<C> : io::Read + fmt::Debug + fmt::Display /// /// but, alas, Rust doesn't like that ("error\[E0119\]: conflicting /// implementations of trait `std::io::Read` for type `&mut _`"). -pub fn buffered_reader_generic_read_impl<T: BufferedReader<C>, C: fmt::Debug> +pub fn buffered_reader_generic_read_impl<T: BufferedReader<C>, C: fmt::Debug + Sync + Send> (bio: &mut T, buf: &mut [u8]) -> Result<usize, io::Error> { match bio.data_consume(buf.len()) { Ok(inner) => { @@ -920,7 +920,7 @@ pub fn buffered_reader_generic_read_impl<T: BufferedReader<C>, C: fmt::Debug> } /// Make a `Box<BufferedReader>` look like a BufferedReader. -impl <'a, C: fmt::Debug> BufferedReader<C> for Box<dyn BufferedReader<C> + 'a> { +impl <'a, C: fmt::Debug + Sync + Send> BufferedReader<C> for Box<dyn BufferedReader<C> + 'a> { fn buffer(&self) -> &[u8] { return self.as_ref().buffer(); } @@ -1018,7 +1018,7 @@ impl <'a, C: fmt::Debug> BufferedReader<C> for Box<dyn BufferedReader<C> + 'a> { // // for i in $(seq 0 9999); do printf "%04d\n" $i; done > buffered-reader-test.txt #[cfg(test)] -fn buffered_reader_test_data_check<'a, T: BufferedReader<C> + 'a, C: fmt::Debug>(bio: &mut T) { +fn buffered_reader_test_data_check<'a, T: BufferedReader<C> + 'a, C: fmt::Debug + Sync + Send>(bio: &mut T) { use std::str; for i in 0 .. 10000 { @@ -1072,7 +1072,7 @@ mod test { } #[cfg(test)] - fn buffered_reader_read_test_aux<'a, T: BufferedReader<C> + 'a, C: fmt::Debug> + fn buffered_reader_read_test_aux<'a, T: BufferedReader<C> + 'a, C: fmt::Debug + Sync + Send> (mut bio: T, data: &[u8]) { let mut buffer = [0; 99]; diff --git a/buffered-reader/src/limitor.rs b/buffered-reader/src/limitor.rs index de75ee5e..16f3897e 100644 --- a/buffered-reader/src/limitor.rs +++ b/buffered-reader/src/limitor.rs @@ -6,7 +6,7 @@ use super::*; /// Limits the amount of data that can be read from a /// `BufferedReader`. #[derive(Debug)] -pub struct Limitor<T: BufferedReader<C>, C: fmt::Debug> { +pub struct Limitor<T: BufferedReader<C>, C: fmt::Debug + Sync + Send> { reader: T, limit: u64, @@ -17,7 +17,7 @@ assert_send_and_sync!(Limitor<T, C> where T: BufferedReader<C>, C: fmt::Debug); -impl<T: BufferedReader<C>, C: fmt::Debug> fmt::Display for Limitor<T, C> { +impl<T: BufferedReader<C>, C: fmt::Debug + Sync + Send> fmt::Display for Limitor<T, C> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("Limitor") .field("limit", &self.limit) @@ -35,7 +35,7 @@ impl<T: BufferedReader<()>> Limitor<T, ()> { } } -impl<T: BufferedReader<C>, C: fmt::Debug> Limitor<T, C> { +impl<T: BufferedReader<C>, C: fmt::Debug + Sync + Send> Limitor<T, C> { /// Like `new()`, but sets a cookie. /// /// The cookie can be retrieved using the `cookie_ref` and @@ -50,7 +50,7 @@ impl<T: BufferedReader<C>, C: fmt::Debug> Limitor<T, C> { } } -impl<T: BufferedReader<C>, C: fmt::Debug> io::Read for Limitor<T, C> { +impl<T: BufferedReader<C>, C: fmt::Debug + Sync + Send> io::Read for Limitor<T, C> { fn read(&mut self, buf: &mut [u8]) -> Result<usize, io::Error> { let len = cmp::min(self.limit, buf.len() as u64) as usize; let result = self.reader.read(&mut buf[0..len]); @@ -61,7 +61,7 @@ impl<T: BufferedReader<C>, C: fmt::Debug> io::Read for Limitor<T, C> { } } -impl<T: BufferedReader<C>, C: fmt::Debug> BufferedReader<C> for Limitor<T, C> { +impl<T: BufferedReader<C>, C: fmt::Debug + Sync + Send> BufferedReader<C> for Limitor<T, C> { fn buffer(&self) -> &[u8] { let buf = self.reader.buffer(); &buf[..cmp::min(buf.len(), diff --git a/buffered-reader/src/memory.rs b/buffered-reader/src/memory.rs index d13dd018..b469a652 100644 --- a/buffered-reader/src/memory.rs +++ b/buffered-reader/src/memory.rs @@ -12,7 +12,7 @@ use super::*; /// buffer, this implementation is optimized for a memory buffer, and /// avoids double buffering. #[derive(Debug)] -pub struct Memory<'a, C: fmt::Debug> { +pub struct Memory<'a, C: fmt::Debug + Sync + Send> { buffer: &'a [u8], // The next byte to read in the buffer. cursor: usize, @@ -24,7 +24,7 @@ pub struct Memory<'a, C: fmt::Debug> { assert_send_and_sync!(Memory<'_, C> where C: fmt::Debug); -impl<'a, C: fmt::Debug> fmt::Display for Memory<'a, C> { +impl<'a, C: fmt::Debug + Sync + Send> fmt::Display for Memory<'a, C> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "Memory ({} of {} bytes read)", self.cursor, self.buffer.len()) @@ -40,7 +40,7 @@ impl<'a> Memory<'a, ()> { } } -impl<'a, C: fmt::Debug> Memory<'a, C> { +impl<'a, C: fmt::Debug + Sync + Send> Memory<'a, C> { /// Like `new()`, but sets a cookie. /// /// The cookie can be retrieved using the `cookie_ref` and @@ -65,7 +65,7 @@ impl<'a, C: fmt::Debug> Memory<'a, C> { } } -impl<'a, C: fmt::Debug> io::Read for Memory<'a, C> { +impl<'a, C: fmt::Debug + Sync + Send> io::Read for Memory<'a, C> { fn read(&mut self, buf: &mut [u8]) -> Result<usize, io::Error> { let amount = cmp::min(buf.len(), self.buffer.len() - self.cursor); buf[0..amount].copy_from_slice( @@ -75,7 +75,7 @@ impl<'a, C: fmt::Debug> io::Read for Memory<'a, C> { } } -impl<'a, C: fmt::Debug> BufferedReader<C> for Memory<'a, C> { +impl<'a, C: fmt::Debug + Sync + Send> BufferedReader<C> for Memory<'a, C> { fn buffer(&self) -> &[u8] { &self.buffer[self.cursor..] } |