Enum jammdb::Data[][src]

pub enum Data {
    Bucket(BucketData),
    KeyValue(KVPair),
}

Key / Value or Bucket Data

The two enum variants represent either a key / value pair or a nested bucket. If you want to access the underneath data, you must match the variant first.

Examples

use jammdb::{DB, Data};

let db = DB::open("my.db")?;
let mut tx = db.tx(true)?;
let bucket = tx.create_bucket("my-bucket")?;

if let Some(data) = bucket.get("my-key") {
    match &*data {
        Data::Bucket(b) => assert_eq!(b.name(), b"my-key"),
        Data::KeyValue(kv) => assert_eq!(kv.key(), b"my-key"),
    }
}

Variants

Bucket(BucketData)

Contains data about a nested bucket

KeyValue(KVPair)

a key / value pair of bytes

Implementations

impl Data[src]

pub fn is_kv(&self) -> bool[src]

Checks if the Data is a KVPair

pub fn kv(&self) -> &KVPair[src]

Asserts that the Data is a KVPair and returns the inner data

This is an ergonomic function since data is wrapped up in a Ref and matching is annoying

Trait Implementations

impl Clone for Data[src]

impl Debug for Data[src]

impl PartialEq<Data> for Data[src]

impl StructuralPartialEq for Data[src]

Auto Trait Implementations

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<T> Same<T> for T

type Output = T

Should always be Self

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.