Trait UnsizedStorable

Source
pub trait UnsizedStorable: Storable {
    const ALIGN: usize;

    // Required methods
    fn size(&self) -> usize;
    unsafe fn onpage_size(_: *const u8) -> usize;
    unsafe fn from_raw_ptr<'a, T>(_: &T, p: *const u8) -> &'a Self;

    // Provided methods
    unsafe fn write_to_page(&self, _: *mut u8) { ... }
    unsafe fn write_to_page_alloc<T: AllocPage>(&self, _: &mut T, p: *mut u8) { ... }
}
Expand description

Types that can be stored on disk.

Required Associated Constants§

Required Methods§

Source

fn size(&self) -> usize

If Self::SIZE.is_some(), this must return the same value. The default implementation is Self;:SIZE.unwrap().

Source

unsafe fn onpage_size(_: *const u8) -> usize

Read the size from an on-page entry. If Self::SIZE.is_some() this must be the same value.

Source

unsafe fn from_raw_ptr<'a, T>(_: &T, p: *const u8) -> &'a Self

Provided Methods§

Source

unsafe fn write_to_page(&self, _: *mut u8)

Write to a page. Must not overwrite the allocated size, but this isn’t checked (which is why it’s unsafe).

Source

unsafe fn write_to_page_alloc<T: AllocPage>(&self, _: &mut T, p: *mut u8)

Write to a page. Must not overwrite the allocated size, but this isn’t checked (which is why it’s unsafe).

This is similar to write_to_page, but allows the user to allocate a value as needed when inserting the value into the base; do not implement both methods, since only write_to_page_alloc gets called by the library.

The default implementation just calls write_to_page.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl UnsizedStorable for i8

Source§

fn size(&self) -> usize

If Self::SIZE.is_some(), this must return the same value. The default implementation is Self;:SIZE.unwrap().

Source§

unsafe fn onpage_size(_: *const u8) -> usize

Read the size from an on-page entry.

Source§

const ALIGN: usize = 1usize

Source§

unsafe fn write_to_page(&self, p: *mut u8)

Source§

unsafe fn from_raw_ptr<'a, T>(_: &T, p: *const u8) -> &'a Self

Source§

impl UnsizedStorable for i16

Source§

fn size(&self) -> usize

If Self::SIZE.is_some(), this must return the same value. The default implementation is Self;:SIZE.unwrap().

Source§

unsafe fn onpage_size(_: *const u8) -> usize

Read the size from an on-page entry.

Source§

const ALIGN: usize = 2usize

Source§

unsafe fn write_to_page(&self, p: *mut u8)

Source§

unsafe fn from_raw_ptr<'a, T>(_: &T, p: *const u8) -> &'a Self

Source§

impl UnsizedStorable for i32

Source§

fn size(&self) -> usize

If Self::SIZE.is_some(), this must return the same value. The default implementation is Self;:SIZE.unwrap().

Source§

unsafe fn onpage_size(_: *const u8) -> usize

Read the size from an on-page entry.

Source§

const ALIGN: usize = 4usize

Source§

unsafe fn write_to_page(&self, p: *mut u8)

Source§

unsafe fn from_raw_ptr<'a, T>(_: &T, p: *const u8) -> &'a Self

Source§

impl UnsizedStorable for i64

Source§

fn size(&self) -> usize

If Self::SIZE.is_some(), this must return the same value. The default implementation is Self;:SIZE.unwrap().

Source§

unsafe fn onpage_size(_: *const u8) -> usize

Read the size from an on-page entry.

Source§

const ALIGN: usize = 8usize

Source§

unsafe fn write_to_page(&self, p: *mut u8)

Source§

unsafe fn from_raw_ptr<'a, T>(_: &T, p: *const u8) -> &'a Self

Source§

impl UnsizedStorable for u8

Source§

fn size(&self) -> usize

If Self::SIZE.is_some(), this must return the same value. The default implementation is Self;:SIZE.unwrap().

Source§

unsafe fn onpage_size(_: *const u8) -> usize

Read the size from an on-page entry.

Source§

const ALIGN: usize = 1usize

Source§

unsafe fn write_to_page(&self, p: *mut u8)

Source§

unsafe fn from_raw_ptr<'a, T>(_: &T, p: *const u8) -> &'a Self

Source§

impl UnsizedStorable for u16

Source§

fn size(&self) -> usize

If Self::SIZE.is_some(), this must return the same value. The default implementation is Self;:SIZE.unwrap().

Source§

unsafe fn onpage_size(_: *const u8) -> usize

Read the size from an on-page entry.

Source§

const ALIGN: usize = 2usize

Source§

unsafe fn write_to_page(&self, p: *mut u8)

Source§

unsafe fn from_raw_ptr<'a, T>(_: &T, p: *const u8) -> &'a Self

Source§

impl UnsizedStorable for u32

Source§

fn size(&self) -> usize

If Self::SIZE.is_some(), this must return the same value. The default implementation is Self;:SIZE.unwrap().

Source§

unsafe fn onpage_size(_: *const u8) -> usize

Read the size from an on-page entry.

Source§

const ALIGN: usize = 4usize

Source§

unsafe fn write_to_page(&self, p: *mut u8)

Source§

unsafe fn from_raw_ptr<'a, T>(_: &T, p: *const u8) -> &'a Self

Source§

impl UnsizedStorable for u64

Source§

fn size(&self) -> usize

If Self::SIZE.is_some(), this must return the same value. The default implementation is Self;:SIZE.unwrap().

Source§

unsafe fn onpage_size(_: *const u8) -> usize

Read the size from an on-page entry.

Source§

const ALIGN: usize = 8usize

Source§

unsafe fn write_to_page(&self, p: *mut u8)

Source§

unsafe fn from_raw_ptr<'a, T>(_: &T, p: *const u8) -> &'a Self

Source§

impl UnsizedStorable for ()

Source§

fn size(&self) -> usize

If Self::SIZE.is_some(), this must return the same value. The default implementation is Self;:SIZE.unwrap().

Source§

unsafe fn onpage_size(_: *const u8) -> usize

Read the size from an on-page entry.

Source§

const ALIGN: usize = 1usize

Source§

unsafe fn write_to_page(&self, p: *mut u8)

Source§

unsafe fn from_raw_ptr<'a, T>(_: &T, p: *const u8) -> &'a Self

Source§

impl UnsizedStorable for [u8; 16]

Source§

fn size(&self) -> usize

If Self::SIZE.is_some(), this must return the same value. The default implementation is Self;:SIZE.unwrap().

Source§

unsafe fn onpage_size(_: *const u8) -> usize

Read the size from an on-page entry.

Source§

const ALIGN: usize = 1usize

Source§

unsafe fn write_to_page(&self, p: *mut u8)

Source§

unsafe fn from_raw_ptr<'a, T>(_: &T, p: *const u8) -> &'a Self

Source§

impl UnsizedStorable for [u8]

Source§

const ALIGN: usize = 2usize

Source§

fn size(&self) -> usize

Source§

unsafe fn from_raw_ptr<'a, T>(_: &T, p: *const u8) -> &'a Self

Source§

unsafe fn onpage_size(p: *const u8) -> usize

Source§

unsafe fn write_to_page_alloc<T: AllocPage>(&self, _txn: &mut T, p: *mut u8)

Implementors§

Source§

impl<'b> UnsizedStorable for Slice<'b>

Source§

const ALIGN: usize = 8usize