changeset 58:8d73d093ef59

Mark all dynamic traits with `dyn`
author Lewin Bormann <lbo@spheniscida.de>
date Sat, 12 Oct 2019 13:27:42 +0200
parents 830eb538a57b
children 6932158e5c0f
files src/filter.rs src/options.rs src/table_block.rs src/table_reader.rs src/types.rs
diffstat 5 files changed, 11 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/filter.rs	Sat Oct 12 13:24:45 2019 +0200
+++ b/src/filter.rs	Sat Oct 12 13:27:42 2019 +0200
@@ -17,7 +17,7 @@
 
 /// A boxed and refcounted filter policy (reference-counted because a Box with unsized content
 /// couldn't be cloned otherwise)
-pub type BoxedFilterPolicy = Rc<Box<FilterPolicy>>;
+pub type BoxedFilterPolicy = Rc<Box<dyn FilterPolicy>>;
 
 impl FilterPolicy for BoxedFilterPolicy {
     fn name(&self) -> &'static str {
--- a/src/options.rs	Sat Oct 12 13:24:45 2019 +0200
+++ b/src/options.rs	Sat Oct 12 13:27:42 2019 +0200
@@ -33,7 +33,7 @@
 /// self-explanatory; the defaults are defined in the `Default` implementation.
 #[derive(Clone)]
 pub struct Options {
-    pub cmp: Rc<Box<Cmp>>,
+    pub cmp: Rc<Box<dyn Cmp>>,
     pub write_buffer_size: usize,
     pub block_cache: Shared<Cache<Block>>,
     pub block_size: usize,
--- a/src/table_block.rs	Sat Oct 12 13:24:45 2019 +0200
+++ b/src/table_block.rs	Sat Oct 12 13:27:42 2019 +0200
@@ -12,14 +12,14 @@
 use snap::Decoder;
 
 /// Reads the data for the specified block handle from a file.
-fn read_bytes(f: &RandomAccess, location: &BlockHandle) -> Result<Vec<u8>> {
+fn read_bytes(f: &dyn RandomAccess, location: &BlockHandle) -> Result<Vec<u8>> {
     let mut buf = vec![0; location.size()];
     f.read_at(location.offset(), &mut buf).map(|_| buf)
 }
 
 /// Reads a serialized filter block from a file and returns a FilterBlockReader.
 pub fn read_filter_block(
-    src: &RandomAccess,
+    src: &dyn RandomAccess,
     location: &BlockHandle,
     policy: filter::BoxedFilterPolicy,
 ) -> Result<FilterBlockReader> {
@@ -36,7 +36,7 @@
 /// Reads a table block from a random-access source.
 /// A table block consists of [bytes..., compress (1B), checksum (4B)]; the handle only refers to
 /// the location and length of [bytes...].
-pub fn read_table_block(opt: Options, f: &RandomAccess, location: &BlockHandle) -> Result<Block> {
+pub fn read_table_block(opt: Options, f: &dyn RandomAccess, location: &BlockHandle) -> Result<Block> {
     // The block is denoted by offset and length in BlockHandle. A block in an encoded
     // table is followed by 1B compression type and 4B checksum.
     // The checksum refers to the compressed contents.
--- a/src/table_reader.rs	Sat Oct 12 13:24:45 2019 +0200
+++ b/src/table_reader.rs	Sat Oct 12 13:27:42 2019 +0200
@@ -16,7 +16,7 @@
 use integer_encoding::FixedIntWriter;
 
 /// Reads the table footer.
-fn read_footer(f: &RandomAccess, size: usize) -> Result<Footer> {
+fn read_footer(f: &dyn RandomAccess, size: usize) -> Result<Footer> {
     let mut buf = vec![0; table_builder::FULL_FOOTER_LENGTH];
     f.read_at(size - table_builder::FULL_FOOTER_LENGTH, &mut buf)?;
     Ok(Footer::decode(&buf))
@@ -25,7 +25,7 @@
 /// `Table` is used for accessing SSTables.
 #[derive(Clone)]
 pub struct Table {
-    file: Rc<Box<RandomAccess>>,
+    file: Rc<Box<dyn RandomAccess>>,
     file_size: usize,
     cache_id: cache::CacheID,
 
@@ -45,7 +45,7 @@
     }
 
     /// Creates a new table reader.
-    pub fn new(opt: Options, file: Box<RandomAccess>, size: usize) -> Result<Table> {
+    pub fn new(opt: Options, file: Box<dyn RandomAccess>, size: usize) -> Result<Table> {
         let footer = try!(read_footer(file.as_ref(), size));
         let indexblock = try!(table_block::read_table_block(
             opt.clone(),
@@ -74,7 +74,7 @@
 
     fn read_filter_block(
         metaix: &Block,
-        file: &RandomAccess,
+        file: &dyn RandomAccess,
         options: &Options,
     ) -> Result<Option<FilterBlockReader>> {
         // Open filter block for reading
--- a/src/types.rs	Sat Oct 12 13:24:45 2019 +0200
+++ b/src/types.rs	Sat Oct 12 13:27:42 2019 +0200
@@ -33,7 +33,7 @@
 
 impl RandomAccess for File {
     fn read_at(&self, off: usize, dst: &mut [u8]) -> Result<usize> {
-        Ok((self as &FileExt).read_at(dst, off as u64)?)
+        Ok((self as &dyn FileExt).read_at(dst, off as u64)?)
     }
 }
 
@@ -106,7 +106,7 @@
     }
 }
 
-impl SSIterator for Box<SSIterator> {
+impl SSIterator for Box<dyn SSIterator> {
     fn advance(&mut self) -> bool {
         self.as_mut().advance()
     }