Trait sanakirja_core::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§
sourcefn size(&self) -> usize
fn size(&self) -> usize
If Self::SIZE.is_some()
, this must return the same
value. The default implementation is Self;:SIZE.unwrap()
.
sourceunsafe fn onpage_size(_: *const u8) -> usize
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.
unsafe fn from_raw_ptr<'a, T>(_: &T, p: *const u8) -> &'a Self
Provided Methods§
sourceunsafe fn write_to_page(&self, _: *mut u8)
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).
sourceunsafe fn write_to_page_alloc<T: AllocPage>(&self, _: &mut T, p: *mut u8)
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
.
Object Safety§
This trait is not object safe.