Trait sanakirja::Representable
source · pub trait Representable: Copy + Debug {
type PageOffsets: Iterator<Item = u64>;
fn onpage_size(&self) -> u16;
unsafe fn write_value(&self, p: *mut u8);
unsafe fn read_value(p: *const u8) -> Self;
unsafe fn cmp_value<T: LoadPage>(&self, txn: &T, x: Self) -> Ordering;
fn page_offsets(&self) -> Self::PageOffsets;
fn alignment() -> Alignment { ... }
unsafe fn skip(p: *mut u8) -> *mut u8 { ... }
fn drop_value<T, R: Rng>(
&self,
_: &mut MutTxn<'_, T>,
_: &mut R
) -> Result<(), Error> { ... }
}
Expand description
Types that can be stored in a Sanakirja database, as keys or values. Some care must be taken when storing things.
Required Associated Types
sourcetype PageOffsets: Iterator<Item = u64>
type PageOffsets: 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
sourcefn onpage_size(&self) -> u16
fn onpage_size(&self) -> u16
How much space this value occupies on the page (not counting alignment padding).
sourceunsafe fn write_value(&self, p: *mut u8)
unsafe fn write_value(&self, p: *mut u8)
Write this value to a u8 pointer, guaranteed to be a multiple of self.alignment()
.
sourceunsafe fn read_value(p: *const u8) -> Self
unsafe fn read_value(p: *const u8) -> Self
Read value from an onpage pointer, guaranteed to be a multiple of self.alignment()
.
sourceunsafe fn cmp_value<T: LoadPage>(&self, txn: &T, x: Self) -> Ordering
unsafe fn cmp_value<T: LoadPage>(&self, txn: &T, x: Self) -> Ordering
Compare a value with an onpage value. The current transaction is sometimes helpful, for instance when the page only stores a pointer to another page.
sourcefn page_offsets(&self) -> Self::PageOffsets
fn page_offsets(&self) -> Self::PageOffsets
If this value is an offset to another page at offset offset
,
return Some(offset)
. Return None
else.