pub struct KVPair<'b, 'tx> { /* private fields */ }
Expand description
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§
Trait Implementations§
source§impl<'b, 'tx> PartialEq<KVPair<'b, 'tx>> for KVPair<'b, 'tx>
impl<'b, 'tx> PartialEq<KVPair<'b, 'tx>> for KVPair<'b, 'tx>
impl<'b, 'tx> Eq for KVPair<'b, 'tx>
impl<'b, 'tx> StructuralEq for KVPair<'b, 'tx>
impl<'b, 'tx> StructuralPartialEq for KVPair<'b, 'tx>
Auto Trait Implementations§
impl<'b, 'tx> RefUnwindSafe for KVPair<'b, 'tx>
impl<'b, 'tx> !Send for KVPair<'b, 'tx>
impl<'b, 'tx> !Sync for KVPair<'b, 'tx>
impl<'b, 'tx> Unpin for KVPair<'b, 'tx>
impl<'b, 'tx> UnwindSafe for KVPair<'b, 'tx>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more