vecdb 0.10.2

High-performance mutable persistent vectors built on rawdb
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use crate::{BytesVecValue, ValueStrategy, variants::raw::RawStrategy};

use super::BytesStrategy;

impl<T: BytesVecValue> RawStrategy<T> for BytesStrategy<T> {
    #[inline(always)]
    unsafe fn read_from_ptr(ptr: *const u8, byte_offset: usize) -> T {
        unsafe {
            if T::IS_NATIVE_LAYOUT {
                (ptr.add(byte_offset) as *const T).read_unaligned()
            } else {
                let slice = std::slice::from_raw_parts(ptr.add(byte_offset), size_of::<T>());
                <BytesStrategy<T> as ValueStrategy<T>>::read(slice).unwrap_unchecked()
            }
        }
    }
}