[][src]Enum sanakirja::value::UnsafeValue

pub enum UnsafeValue {
    Direct {
        p: *const u8,
        len: u64,
    },
    Large {
        offset: u64,
        len: u64,
    },
}

Unsafe values, the unsafe representation of a value.

Variants

Direct

A "direct" value, i.e. a value stored inline in tree pages. These values are limited to at most 506 bytes.

Fields of Direct

p: *const u8

Pointer to the first byte of this value.

len: u64

Length of this value, in bytes

Large

A "large" value, stored on a linked list of pages.

Fields of Large

offset: u64

Offset in the file to the first page of this value.

len: u64

Length of this value

Methods

impl UnsafeValue[src]

pub fn len(&self) -> u64[src]

Length of this unsafe value

pub unsafe fn as_slice<'a>(&self) -> &'a [u8][src]

Unsafely turn this value into a slice, if it is inlined on a page. Panics else.

pub fn from_slice(slice: &[u8]) -> UnsafeValue[src]

Converts a slice of bytes into an unsafe value.

pub fn alloc_if_needed<T>(
    txn: &mut MutTxn<T>,
    value: &[u8]
) -> Result<UnsafeValue, Error>
[src]

Allocates a large value if needed, or else return a pointer to the given slice.

Trait Implementations

impl Representable for UnsafeValue[src]

type PageOffsets = IntoIter<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. Read more

fn alignment() -> Alignment[src]

Alignment of this type. Allowed values are 1, 2, 4 and 8.

unsafe fn skip(p: *mut u8) -> *mut u8[src]

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. Read more

impl Clone for UnsafeValue[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Copy for UnsafeValue[src]

impl Debug for UnsafeValue[src]

Auto Trait Implementations

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]