pub struct Store { /* private fields */ }
unstable
only.Expand description
A key value store
Implementations
sourceimpl Store
impl Store
sourcepub fn status(&self) -> Result<BucketStatus>
pub fn status(&self) -> Result<BucketStatus>
Returns the status of the bucket
sourcepub fn entry(&self, key: &str) -> Result<Option<Entry>>
pub fn entry(&self, key: &str) -> Result<Option<Entry>>
Returns the latest entry for the key, if any.
Examples
bucket.put("foo", b"bar")?;
let maybe_entry = bucket.entry("foo")?;
if let Some(entry) = maybe_entry {
println!("Found entry {:?}", entry);
}
sourcepub fn get(&self, key: &str) -> Result<Option<Vec<u8>>>
pub fn get(&self, key: &str) -> Result<Option<Vec<u8>>>
Returns the latest value for the key, if any.
Examples
bucket.put("foo", b"bar")?;
let maybe_value = bucket.get("foo")?;
if let Some(value) = maybe_value {
println!("Found value {:?}", value);
}
sourcepub fn create(&self, key: &str, value: impl AsRef<[u8]>) -> Result<u64>
pub fn create(&self, key: &str, value: impl AsRef<[u8]>) -> Result<u64>
Creates the key/value pair if it does not exist or is marked for deletion.
Examples
bucket.purge("foo")?;
bucket.create("foo", b"bar")?;
sourcepub fn update(
&self,
key: &str,
value: impl AsRef<[u8]>,
revision: u64
) -> Result<u64>
pub fn update(
&self,
key: &str,
value: impl AsRef<[u8]>,
revision: u64
) -> Result<u64>
Updates the value if the latest revision matches.
Examples
let revision = bucket.put("foo", b"bar")?;
let new_revision = bucket.update("foo", b"baz", revision)?;
sourcepub fn delete(&self, key: &str) -> Result<()>
pub fn delete(&self, key: &str) -> Result<()>
Marks an entry as deleted by placing a delete marker but leaves the revision history intact.
Examples
bucket.create("foo", b"bar")?;
bucket.delete("foo")?;
sourcepub fn purge(&self, key: &str) -> Result<()>
pub fn purge(&self, key: &str) -> Result<()>
Remove any entries associated with the key and all historical revisions.
Examples
bucket.create("foo", b"bar")?;
bucket.purge("foo")?;
sourcepub fn keys(&self) -> Result<Keys>
pub fn keys(&self) -> Result<Keys>
Returns an iterator which iterate over all the current keys.
Examples
bucket.put("foo", b"fizz")?;
bucket.put("bar", b"buzz")?;
let mut keys = bucket.keys()?;
assert_eq!(keys.next(), Some("foo".to_string()));
assert_eq!(keys.next(), Some("bar".to_string()));
sourcepub fn history(&self, key: &str) -> Result<History>
pub fn history(&self, key: &str) -> Result<History>
Returns an iterator which iterates over each entry in historical order.
Examples
let bucket = context.create_key_value(&Config {
bucket: "history_iter".to_string(),
history: 2,
..Default::default()
})?;
bucket.put("foo", b"fizz")?;
bucket.put("foo", b"buzz")?;
let mut history = bucket.history("foo")?;
let next = history.next().unwrap();
assert_eq!(next.key, "foo".to_string());
assert_eq!(next.value, b"fizz");
let next = history.next().unwrap();
assert_eq!(next.key, "foo".to_string());
assert_eq!(next.value, b"buzz");
sourcepub fn watch_all(&self) -> Result<Watch>
pub fn watch_all(&self) -> Result<Watch>
Returns an iterator which iterates over each entry as they happen.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Store
impl Send for Store
impl Sync for Store
impl Unpin for Store
impl !UnwindSafe for Store
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more