Struct nats::kv::Store

source · []
pub struct Store { /* private fields */ }
Available on crate feature unstable only.
Expand description

A key value store

Implementations

Returns the status of the bucket

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);
}

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);
}

Places the new value for the key into the bucket.

Examples
bucket.put("foo", b"bar")?;

Creates the key/value pair if it does not exist or is marked for deletion.

Examples
bucket.purge("foo")?;
bucket.create("foo", b"bar")?;

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)?;

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")?;

Remove any entries associated with the key and all historical revisions.

Examples
bucket.create("foo", b"bar")?;
bucket.purge("foo")?;

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()));

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");

Returns an iterator which iterates over each entry as they happen.

Returns an iterator which iterates over each entry for specific key pattern as they happen.

Returns the name of the bucket

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.