diff --git a/src/table.rs b/src/table.rs index 9d004ef5..dd3d2ff7 100644 --- a/src/table.rs +++ b/src/table.rs @@ -3,7 +3,7 @@ use crate::tree_store::{ AccessGuardMut, Btree, BtreeDrain, BtreeDrainFilter, BtreeMut, BtreeRangeIter, Checksum, PageHint, PageNumber, RawBtree, TransactionalMemory, MAX_VALUE_LENGTH, }; -use crate::types::{RedbKey, RedbValue, RedbValueMutInPlace}; +use crate::types::{MutInPlaceValue, RedbKey, RedbValue}; use crate::{AccessGuard, StorageError, WriteTransaction}; use crate::{Result, TableHandle}; use std::borrow::Borrow; @@ -186,7 +186,7 @@ impl<'db, 'txn, K: RedbKey + 'static, V: RedbValue + 'static> Table<'db, 'txn, K } } -impl<'db, 'txn, K: RedbKey + 'static, V: RedbValueMutInPlace + 'static> Table<'db, 'txn, K, V> { +impl<'db, 'txn, K: RedbKey + 'static, V: MutInPlaceValue + 'static> Table<'db, 'txn, K, V> { /// Reserve space to insert a key-value pair /// The returned reference will have length equal to value_length pub fn insert_reserve<'a>( diff --git a/src/tree_store/btree.rs b/src/tree_store/btree.rs index 4366dcbc..be021413 100644 --- a/src/tree_store/btree.rs +++ b/src/tree_store/btree.rs @@ -8,7 +8,7 @@ use crate::tree_store::page_store::{CachePriority, Page, PageImpl, PageMut, Tran use crate::tree_store::{ AccessGuardMut, AllPageNumbersBtreeIter, BtreeDrainFilter, BtreeRangeIter, PageHint, PageNumber, }; -use crate::types::{RedbKey, RedbValue, RedbValueMutInPlace}; +use crate::types::{MutInPlaceValue, RedbKey, RedbValue}; use crate::{AccessGuard, Result}; #[cfg(feature = "logging")] use log::trace; @@ -429,7 +429,7 @@ impl<'a, K: RedbKey + 'a, V: RedbValue + 'a> BtreeMut<'a, K, V> { } } -impl<'a, K: RedbKey + 'a, V: RedbValueMutInPlace + 'a> BtreeMut<'a, K, V> { +impl<'a, K: RedbKey + 'a, V: MutInPlaceValue + 'a> BtreeMut<'a, K, V> { /// Reserve space to insert a key-value pair /// The returned reference will have length equal to value_length // Return type has the same lifetime as &self, because the tree must not be modified until the mutable guard is dropped diff --git a/src/tree_store/btree_base.rs b/src/tree_store/btree_base.rs index 0547a02f..0c84fd66 100644 --- a/src/tree_store/btree_base.rs +++ b/src/tree_store/btree_base.rs @@ -2,7 +2,7 @@ use crate::tree_store::page_store::{ xxh3_checksum, CachePriority, Page, PageImpl, PageMut, TransactionalMemory, }; use crate::tree_store::PageNumber; -use crate::types::{RedbKey, RedbValue, RedbValueMutInPlace}; +use crate::types::{MutInPlaceValue, RedbKey, RedbValue}; use crate::{Result, StorageError}; use std::cmp::Ordering; use std::marker::PhantomData; @@ -204,7 +204,7 @@ impl<'a, V: RedbValue> AccessGuardMut<'a, V> { } } -impl<'a, V: RedbValueMutInPlace> AsMut for AccessGuardMut<'a, V> { +impl<'a, V: MutInPlaceValue> AsMut for AccessGuardMut<'a, V> { fn as_mut(&mut self) -> &mut V::BaseRefType { V::from_bytes_mut(&mut self.page.memory_mut()[self.offset..(self.offset + self.len)]) } diff --git a/src/tree_store/table_tree.rs b/src/tree_store/table_tree.rs index e7279279..b46baf19 100644 --- a/src/tree_store/table_tree.rs +++ b/src/tree_store/table_tree.rs @@ -6,7 +6,7 @@ use crate::tree_store::btree::{btree_stats, UntypedBtreeMut}; use crate::tree_store::btree_base::Checksum; use crate::tree_store::btree_iters::AllPageNumbersBtreeIter; use crate::tree_store::{BtreeMut, BtreeRangeIter, PageNumber, RawBtree, TransactionalMemory}; -use crate::types::{RedbKey, RedbValue, RedbValueMutInPlace, TypeName}; +use crate::types::{MutInPlaceValue, RedbKey, RedbValue, TypeName}; use crate::{DatabaseStats, Result}; use std::cmp::max; use std::collections::{HashMap, HashSet}; @@ -158,7 +158,7 @@ impl RedbValue for FreedPageList<'_> { } } -impl RedbValueMutInPlace for FreedPageList<'_> { +impl MutInPlaceValue for FreedPageList<'_> { type BaseRefType = FreedPageListMut; fn initialize(data: &mut [u8]) { diff --git a/src/types.rs b/src/types.rs index 3aae5cb6..86156ef9 100644 --- a/src/types.rs +++ b/src/types.rs @@ -101,7 +101,7 @@ pub trait RedbValue: Debug { /// Implementing this trait indicates that the type can be mutated in-place as a &mut [u8]. /// This enables the .insert_reserve() method on Table -pub trait RedbValueMutInPlace: RedbValue { +pub trait MutInPlaceValue: RedbValue { /// The base type such that &mut [u8] can be safely transmuted to &mut BaseRefType type BaseRefType: Debug + ?Sized; @@ -112,7 +112,7 @@ pub trait RedbValueMutInPlace: RedbValue { fn from_bytes_mut(data: &mut [u8]) -> &mut Self::BaseRefType; } -impl RedbValueMutInPlace for &[u8] { +impl MutInPlaceValue for &[u8] { type BaseRefType = [u8]; fn initialize(_data: &mut [u8]) {