pub trait Storable: Debug {
    type PageReferences: Iterator<Item = u64>;

    // Required method
    fn page_references(&self) -> Self::PageReferences;

    // Provided methods
    fn compare<T: LoadPage>(&self, _txn: &T, _b: &Self) -> Ordering { ... }
    unsafe fn drop<T: AllocPage>(&self, txn: &mut T) -> Result<(), T::Error> { ... }
}
Expand description

Types that can be stored on disk. This trait may be used in conjunction with Sized in order to determine the on-disk size, or with UnsizedStorable when special arrangements are needed.

The size limit for an entry depends on the datastructure. For B trees, nodes are guaranteed to be at least half-full (i.e. at least 2kiB), and we need at least two entries in each page in order to be able to rebalance in a deletion. A sufficient condition for this is that the size of any entry is less than 1/4th of the blocks. Now, internal nodes need 16 bytes of block header, and then 8 extra bytes for each entry. Entries must therefore not exceed 4080/4 - 8 = 1012 bytes.

Required Associated Types§

source

type PageReferences: Iterator<Item = u64>

An iterator over the offsets to pages contained in this value. Only values from this crate can generate non-empty iterators, but combined values (like tuples) must chain the iterators returned by method page_offsets.

Required Methods§

source

fn page_references(&self) -> Self::PageReferences

If this value is an offset to another page at offset offset, return Some(offset). Return None else.

Provided Methods§

source

fn compare<T: LoadPage>(&self, _txn: &T, _b: &Self) -> Ordering

This is required for B trees, not necessarily for other structures. The default implementation panics.

source

unsafe fn drop<T: AllocPage>(&self, txn: &mut T) -> Result<(), T::Error>

If this value is an offset to another page at offset offset, return Some(offset). Return None else.

§Safety

The caller must not keep any reference to the deleted value.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Storable for i8

source§

impl Storable for i16

source§

impl Storable for i32

source§

impl Storable for i64

source§

impl Storable for u8

source§

impl Storable for u16

source§

impl Storable for u32

source§

impl Storable for u64

source§

impl Storable for ()

source§

impl Storable for [u8; 16]

source§

impl Storable for [u8]

source§

impl<K: Storable, V: Storable, P: BTreePage<K, V> + Debug> Storable for Option<Db_<K, V, P>>

§

type PageReferences = Once<u64>

source§

fn page_references(&self) -> Self::PageReferences

source§

unsafe fn drop<T: AllocPage>(&self, t: &mut T) -> Result<(), T::Error>

Implementors§

source§

impl<'a> Storable for Slice<'a>

source§

impl<K: Storable, V: Storable, P: BTreePage<K, V> + Debug> Storable for Db_<K, V, P>