[−][src]Trait sanakirja::Representable
Types that can be stored in a Sanakirja database, as keys or values. Some care must be taken when storing things.
Associated Types
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
fn onpage_size(&self) -> u16
How much space this value occupies on the page (not counting alignment padding).
unsafe fn write_value(&self, p: *mut u8)
Write this value to a u8 pointer, guaranteed to be a multiple of self.alignment()
.
unsafe fn read_value(p: *const u8) -> Self
Read value from an onpage pointer, guaranteed to be a multiple of self.alignment()
.
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.
fn page_offsets(&self) -> Self::PageOffsets
If this value is an offset to another page at offset offset
,
return Some(offset)
. Return None
else.
Provided methods
fn alignment() -> Alignment
Alignment of this type. Allowed values are 1, 2, 4 and 8.
unsafe fn skip(p: *mut u8) -> *mut u8
First pointer strictly after this value's pointer. The default
implementation is basically p.offset(self.onpage_size() as isize)
, but their might be more efficient implementations in
some cases.
fn drop_value<T, R: Rng>(
&self,
_: &mut MutTxn<T>,
_: &mut R
) -> Result<(), Error>
&self,
_: &mut MutTxn<T>,
_: &mut R
) -> Result<(), Error>
How to free the pages used by this value. The default implementation doesn't do anything, which is fine for types stored directly on B tree pages.
Implementations on Foreign Types
impl<A: Representable, B: Representable> Representable for (A, B)
[src]
fn alignment() -> Alignment
[src]
fn onpage_size(&self) -> u16
[src]
unsafe fn write_value(&self, p: *mut u8)
[src]
unsafe fn read_value(p: *const u8) -> Self
[src]
unsafe fn cmp_value<T: LoadPage>(&self, txn: &T, x: Self) -> Ordering
[src]
type PageOffsets = Chain<A::PageOffsets, B::PageOffsets>
fn page_offsets(&self) -> Self::PageOffsets
[src]
fn drop_value<T, R: Rng>(
&self,
txn: &mut MutTxn<T>,
rng: &mut R
) -> Result<(), Error>
[src]
&self,
txn: &mut MutTxn<T>,
rng: &mut R
) -> Result<(), Error>
impl<A: Representable, B: Representable, C: Representable> Representable for (A, B, C)
[src]
fn alignment() -> Alignment
[src]
fn onpage_size(&self) -> u16
[src]
unsafe fn write_value(&self, p: *mut u8)
[src]
unsafe fn read_value(p: *const u8) -> Self
[src]
unsafe fn cmp_value<T: LoadPage>(&self, txn: &T, x: Self) -> Ordering
[src]
type PageOffsets = Chain<Chain<A::PageOffsets, B::PageOffsets>, C::PageOffsets>
fn page_offsets(&self) -> Self::PageOffsets
[src]
fn drop_value<T, R: Rng>(
&self,
txn: &mut MutTxn<T>,
rng: &mut R
) -> Result<(), Error>
[src]
&self,
txn: &mut MutTxn<T>,
rng: &mut R
) -> Result<(), Error>
impl<A: Representable, B: Representable, C: Representable, D: Representable> Representable for (A, B, C, D)
[src]
fn alignment() -> Alignment
[src]
fn onpage_size(&self) -> u16
[src]
unsafe fn write_value(&self, p: *mut u8)
[src]
unsafe fn read_value(p: *const u8) -> Self
[src]
unsafe fn cmp_value<T: LoadPage>(&self, txn: &T, x: Self) -> Ordering
[src]
type PageOffsets = Chain<Chain<A::PageOffsets, B::PageOffsets>, Chain<C::PageOffsets, D::PageOffsets>>
fn page_offsets(&self) -> Self::PageOffsets
[src]
fn drop_value<T, R: Rng>(
&self,
txn: &mut MutTxn<T>,
rng: &mut R
) -> Result<(), Error>
[src]
&self,
txn: &mut MutTxn<T>,
rng: &mut R
) -> Result<(), Error>
impl Representable for f64
[src]
fn alignment() -> Alignment
[src]
fn onpage_size(&self) -> u16
[src]
unsafe fn skip(p: *mut u8) -> *mut u8
[src]
unsafe fn write_value(&self, p: *mut u8)
[src]
unsafe fn read_value(p: *const u8) -> Self
[src]
unsafe fn cmp_value<T: LoadPage>(&self, _: &T, x: Self) -> Ordering
[src]
type PageOffsets = Empty<u64>
fn page_offsets(&self) -> Self::PageOffsets
[src]
impl Representable for u64
[src]
fn alignment() -> Alignment
[src]
fn onpage_size(&self) -> u16
[src]
unsafe fn skip(p: *mut u8) -> *mut u8
[src]
unsafe fn write_value(&self, p: *mut u8)
[src]
unsafe fn read_value(p: *const u8) -> Self
[src]
unsafe fn cmp_value<T: LoadPage>(&self, _: &T, x: Self) -> Ordering
[src]
type PageOffsets = Empty<u64>
fn page_offsets(&self) -> Self::PageOffsets
[src]
impl Representable for u32
[src]
fn alignment() -> Alignment
[src]
fn onpage_size(&self) -> u16
[src]
unsafe fn skip(p: *mut u8) -> *mut u8
[src]
unsafe fn write_value(&self, p: *mut u8)
[src]
unsafe fn read_value(p: *const u8) -> Self
[src]
unsafe fn cmp_value<T: LoadPage>(&self, _: &T, x: Self) -> Ordering
[src]
type PageOffsets = Empty<u64>
fn page_offsets(&self) -> Self::PageOffsets
[src]
impl Representable for i64
[src]
fn alignment() -> Alignment
[src]
fn onpage_size(&self) -> u16
[src]
unsafe fn skip(p: *mut u8) -> *mut u8
[src]
unsafe fn write_value(&self, p: *mut u8)
[src]
unsafe fn read_value(p: *const u8) -> Self
[src]
unsafe fn cmp_value<T: LoadPage>(&self, _: &T, x: Self) -> Ordering
[src]
type PageOffsets = Empty<u64>
fn page_offsets(&self) -> Self::PageOffsets
[src]
impl Representable for i32
[src]
fn alignment() -> Alignment
[src]
fn onpage_size(&self) -> u16
[src]
unsafe fn skip(p: *mut u8) -> *mut u8
[src]
unsafe fn write_value(&self, p: *mut u8)
[src]
unsafe fn read_value(p: *const u8) -> Self
[src]
unsafe fn cmp_value<T: LoadPage>(&self, _: &T, x: Self) -> Ordering
[src]
type PageOffsets = Empty<u64>
fn page_offsets(&self) -> Self::PageOffsets
[src]
impl Representable for ()
[src]
fn alignment() -> Alignment
[src]
fn onpage_size(&self) -> u16
[src]
unsafe fn skip(p: *mut u8) -> *mut u8
[src]
unsafe fn write_value(&self, _: *mut u8)
[src]
unsafe fn read_value(_: *const u8) -> Self
[src]
unsafe fn cmp_value<T: LoadPage>(&self, _: &T, _: Self) -> Ordering
[src]
type PageOffsets = Empty<u64>
fn page_offsets(&self) -> Self::PageOffsets
[src]
Implementors
impl Representable for UnsafeValue
[src]
fn onpage_size(&self) -> u16
[src]
unsafe fn write_value(&self, ptr: *mut u8)
[src]
unsafe fn read_value(ptr: *const u8) -> Self
[src]
unsafe fn cmp_value<T: LoadPage>(&self, txn: &T, y: Self) -> Ordering
[src]
fn drop_value<T, R>(&self, txn: &mut MutTxn<T>, _: &mut R) -> Result<(), Error>
[src]
type PageOffsets = IntoIter<u64>
fn page_offsets(&self) -> Self::PageOffsets
[src]
impl<K: Representable, V: Representable> Representable for Db<K, V>
[src]
fn alignment() -> Alignment
[src]
fn onpage_size(&self) -> u16
[src]
unsafe fn skip(p: *mut u8) -> *mut u8
[src]
unsafe fn write_value(&self, p: *mut u8)
[src]
unsafe fn read_value(p: *const u8) -> Self
[src]
unsafe fn cmp_value<T: LoadPage>(&self, _: &T, x: Db<K, V>) -> Ordering
[src]
type PageOffsets = Once<u64>
fn page_offsets(&self) -> Self::PageOffsets
[src]
fn drop_value<T, R: Rng>(
&self,
txn: &mut MutTxn<T>,
rng: &mut R
) -> Result<(), Error>
[src]
&self,
txn: &mut MutTxn<T>,
rng: &mut R
) -> Result<(), Error>