[][src]Enum sanakirja::value::Value

pub enum Value<'a, T: 'a> {
    Direct {
        p: *const u8,
        len: u64,
        txn: PhantomData<&'a T>,
    },
    Large {
        txn: &'a T,
        offset: u64,
        len: u64,
    },
}

Iterator over parts of a value. On values of size at most 4096 bytes, the iterator will run exactly once. On larger values, it returns all parts of the value, in order.

Variants

Direct

On-page value.

Fields of Direct

p: *const u8

Pointer to the value.

len: u64

Length.

txn: PhantomData<&'a T>

Lifetime marker.

Large

Indirect value, just an offset to a page and a length are stored on the page, as two u64.

Fields of Large

txn: &'a T

Transaction from which this page can be retrieved.

offset: u64

Offset of the page from the beginning of the file.

len: u64

Total length of this value.

Implementations

impl<'a, T: LoadPage> Value<'a, T>[src]

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

Length of this value.

pub fn clone(&self) -> Value<'a, T>

Notable traits for Value<'a, T>

impl<'a, T: LoadPage> Iterator for Value<'a, T> type Item = &'a [u8];
[src]

Clone the pointers to this value. This is actually unsafe, as it duplicates a pointer, and several copies might be stored in the database without incrementing their RC.

As long as it is never put back into a database, it should be safe.

pub unsafe fn from_unsafe(u: &UnsafeValue, txn: &'a T) -> Value<'a, T>

Notable traits for Value<'a, T>

impl<'a, T: LoadPage> Iterator for Value<'a, T> type Item = &'a [u8];
[src]

Turns an UnsafeValue into a Value. The database from which that UnsafeValue comes must not have changed since the UnsafeValue was retrieved.

pub fn to_unsafe(&self) -> UnsafeValue[src]

Turns a value into an unsafe value, ready to be inserted into a database.

pub fn from_slice(slice: &'a [u8]) -> Value<'a, T>

Notable traits for Value<'a, T>

impl<'a, T: LoadPage> Iterator for Value<'a, T> type Item = &'a [u8];
[src]

Produces a direct value from a slice. Might exceed the maximal page size.

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

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

pub fn try_as_slice(&self) -> Option<&'a [u8]>[src]

Turn this value into a slice, if it is inlined on a page.

pub fn into_cow(&'a self) -> Cow<'a, [u8]>[src]

Turns this value into a std::borrow::Cow, allocating a Vec<u8> if it is too large.

Trait Implementations

impl<'a, T: Clone + 'a> Clone for Value<'a, T>[src]

impl<'a, T: Copy + 'a> Copy for Value<'a, T>[src]

impl<'a, T: LoadPage> Debug for Value<'a, T>[src]

impl<'b, T: LoadPage + 'b> Eq for Value<'b, T>[src]

impl<'b, T: LoadPage + 'b> Hash for Value<'b, T>[src]

impl<'a, T: LoadPage> Iterator for Value<'a, T>[src]

type Item = &'a [u8]

The type of the elements being iterated over.

impl<'a, 'b, T: LoadPage + 'b> PartialEq<&'a [u8]> for Value<'b, T>[src]

impl<'b, T: LoadPage + 'b> PartialEq<[u8]> for Value<'b, T>[src]

impl<'a, 'b, A: LoadPage + 'a, B: LoadPage + 'b> PartialEq<Value<'a, A>> for Value<'b, B>[src]

impl<'b, T: LoadPage + 'b> PartialEq<Value<'b, T>> for [u8][src]

impl<'a, 'b, T: LoadPage + 'b> PartialEq<Value<'b, T>> for &'a [u8][src]

Auto Trait Implementations

impl<'a, T> RefUnwindSafe for Value<'a, T> where
    T: RefUnwindSafe

impl<'a, T> !Send for Value<'a, T>

impl<'a, T> !Sync for Value<'a, T>

impl<'a, T> Unpin for Value<'a, T>

impl<'a, T> UnwindSafe for Value<'a, T> where
    T: RefUnwindSafe

Blanket Implementations

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

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

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

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

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

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<I> IteratorRandom for I where
    I: Iterator
[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<V, T> VZip<V> for T where
    V: MultiLane<T>,