From 9c28085c8465929b66b2ab10287b7ad087d2b7c7 Mon Sep 17 00:00:00 2001 From: Douglas Dwyer Date: Thu, 7 Dec 2023 12:47:04 -0500 Subject: [PATCH] Update fallback.rs --- src/tree_store/page_store/file_backend/fallback.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tree_store/page_store/file_backend/fallback.rs b/src/tree_store/page_store/file_backend/fallback.rs index 6b8bedc1..188c79d3 100644 --- a/src/tree_store/page_store/file_backend/fallback.rs +++ b/src/tree_store/page_store/file_backend/fallback.rs @@ -13,9 +13,9 @@ pub struct FileBackend { impl FileBackend { /// Creates a new backend which stores data to the given file. pub fn new(file: File) -> Result { - Self { + Ok(Self { file: Mutex::new(file), - } + }) } } @@ -26,7 +26,7 @@ impl StorageBackend for FileBackend { fn read(&self, offset: u64, len: usize) -> Result, io::Error> { let mut result = vec![0; len]; - let file = self.file.lock().unwrap(); + let mut file = self.file.lock().unwrap(); file.seek(SeekFrom::Start(offset))?; file.read_exact(&mut result)?; Ok(result) @@ -41,7 +41,7 @@ impl StorageBackend for FileBackend { } fn write(&self, offset: u64, data: &[u8]) -> Result<(), io::Error> { - let file = self.file.lock().unwrap(); + let mut file = self.file.lock().unwrap(); file.seek(SeekFrom::Start(offset))?; file.write_all(data) }