Struct jammdb::KVPair[][src]

pub struct KVPair { /* fields omitted */ }

Key / Value Pair

You can use the key and value methods to access the underlying byte slices. The data is only valid for the life of the transaction, so make a copy if you want to keep it around longer than that.

Examples

use jammdb::{DB, Data};

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

// put a key / value pair into the bucket
bucket.put("my-key", "my-value")?;
if let Some(data) = bucket.get("my-key") {
    if let Data::KeyValue(kv) = &*data {
        let key: &[u8] = kv.key();
        let value: &[u8] = kv.value();
        assert_eq!(key, b"my-key");
        assert_eq!(value, b"my-value");
    }
}

Implementations

impl KVPair[src]

pub fn key(&self) -> &[u8][src]

Returns the key of the key / value pair as a byte slice.

pub fn value(&self) -> &[u8][src]

Returns the value of the key / value pair as a byte slice.

Trait Implementations

impl Clone for KVPair[src]

impl Debug for KVPair[src]

impl PartialEq<KVPair> for KVPair[src]

impl StructuralPartialEq for KVPair[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.