diff --git a/src/storage/storage_vec.rs b/src/storage/storage_vec.rs index 317156aa3..6dac07814 100644 --- a/src/storage/storage_vec.rs +++ b/src/storage/storage_vec.rs @@ -6,7 +6,7 @@ use crate::db_error::DbError; #[allow(dead_code)] pub(crate) struct StorageVec { storage: std::rc::Rc>, - file_index: i64, + storage_index: i64, size: u64, capacity: u64, phantom_data: std::marker::PhantomData, @@ -14,8 +14,8 @@ pub(crate) struct StorageVec { #[allow(dead_code)] impl StorageVec { - pub(crate) fn file_index(&self) -> i64 { - self.file_index + pub(crate) fn storage_index(&self) -> i64 { + self.storage_index } pub(crate) fn len(&self) -> u64 { @@ -28,9 +28,9 @@ impl StorageVec { } let mut ref_storage = self.storage.borrow_mut(); - ref_storage.insert_at(self.file_index, Self::value_offset(self.size), value)?; + ref_storage.insert_at(self.storage_index, Self::value_offset(self.size), value)?; self.size += 1; - ref_storage.insert_at(self.file_index, 0, &self.size)?; + ref_storage.insert_at(self.storage_index, 0, &self.size)?; Ok(()) } @@ -42,7 +42,7 @@ impl StorageVec { self.storage .borrow_mut() - .insert_at(self.file_index, Self::value_offset(index), value) + .insert_at(self.storage_index, Self::value_offset(index), value) } pub(crate) fn value(&mut self, index: u64) -> Result { @@ -52,14 +52,14 @@ impl StorageVec { self.storage .borrow_mut() - .value_at::(self.file_index, Self::value_offset(index)) + .value_at::(self.storage_index, Self::value_offset(index)) } fn reallocate(&mut self, new_capacity: u64) -> Result<(), DbError> { self.capacity = new_capacity; self.storage .borrow_mut() - .resize_value(self.file_index, Self::value_offset(new_capacity)) + .resize_value(self.storage_index, Self::value_offset(new_capacity)) } fn value_offset(index: u64) -> u64 { @@ -75,7 +75,7 @@ impl TryFrom>> for S Ok(Self { storage, - file_index: index, + storage_index: index, size: 0, capacity: 0, phantom_data: std::marker::PhantomData::, @@ -90,7 +90,7 @@ impl IntoIterator for &mut StorageVec { fn into_iter(self) -> Self::IntoIter { self.storage .borrow_mut() - .value::>(self.file_index) + .value::>(self.storage_index) .unwrap_or_default() .into_iter() } @@ -150,7 +150,9 @@ mod tests { vec.push(&5).unwrap(); assert_eq!( - storage.borrow_mut().value::>(vec.file_index()), + storage + .borrow_mut() + .value::>(vec.storage_index()), Ok(vec![1_i64, 3_i64, 5_i64]) ); }