Struct jammdb::KVPair [−][src]
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
impl RefUnwindSafe for KVPair
[src]
impl !Send for KVPair
[src]
impl !Sync for KVPair
[src]
impl Unpin for KVPair
[src]
impl UnwindSafe for KVPair
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,