From cdd0beb527f9c67610c6e4430645fb4f6ef17098 Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Tue, 18 Aug 2020 12:57:05 +0100 Subject: [PATCH] [thin_check (rust)] Change io_engine trait to use slices rather than Vecs --- src/io_engine.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/io_engine.rs b/src/io_engine.rs index 91e95b8..fbc71a2 100644 --- a/src/io_engine.rs +++ b/src/io_engine.rs @@ -50,10 +50,9 @@ unsafe impl Send for Block {} pub trait IoEngine { fn get_nr_blocks(&self) -> u64; fn read(&self, block: &mut Block) -> Result<()>; - // FIXME: change to &[Block] - fn read_many(&self, blocks: &mut Vec) -> Result<()>; + fn read_many(&self, blocks: &mut [Block]) -> Result<()>; fn write(&self, block: &Block) -> Result<()>; - fn write_many(&self, blocks: &Vec) -> Result<()>; + fn write_many(&self, blocks: &[Block]) -> Result<()>; } fn get_nr_blocks(path: &Path) -> io::Result { @@ -123,7 +122,7 @@ impl IoEngine for SyncIoEngine { Ok(()) } - fn read_many(&self, blocks: &mut Vec) -> Result<()> { + fn read_many(&self, blocks: &mut [Block]) -> Result<()> { let mut input = self.get(); for b in blocks { input.seek(io::SeekFrom::Start(b.loc * BLOCK_SIZE as u64))?; @@ -143,7 +142,7 @@ impl IoEngine for SyncIoEngine { Ok(()) } - fn write_many(&self, blocks: &Vec) -> Result<()> { + fn write_many(&self, blocks: &[Block]) -> Result<()> { let mut input = self.get(); for b in blocks { input.seek(io::SeekFrom::Start(b.loc * BLOCK_SIZE as u64))?; @@ -300,7 +299,7 @@ impl IoEngine for AsyncIoEngine { Ok(()) } - fn read_many(&self, blocks: &mut Vec) -> Result<()> { + fn read_many(&self, blocks: &mut [Block]) -> Result<()> { let inner = self.inner.lock().unwrap(); let queue_len = inner.queue_len as usize; drop(inner); @@ -340,7 +339,7 @@ impl IoEngine for AsyncIoEngine { Ok(()) } - fn write_many(&self, blocks: &Vec) -> Result<()> { + fn write_many(&self, blocks: &[Block]) -> Result<()> { let inner = self.inner.lock().unwrap(); let queue_len = inner.queue_len as usize; drop(inner);