Rust

key_value

Module

A key-value store on a JetStream stream (KV_<bucket>).

Contents

use utopia_nats::key_value::KeyValue;
Rust
pub struct KeyValue

A key-value bucket.

Rust
use utopia_nats::key_value::KeyValueConfig;
let js = connection.jetstream(None, None);
let kv = js.create_key_value(&mut connection, &KeyValueConfig { history: 5, ..KeyValueConfig::new("doc_config") }).await?;
let revision = kv.put(&mut connection, "app.name", "My Service").await?;
let entry = kv.get(&mut connection, "app.name").await?;
assert_eq!((entry.value.as_ref(), entry.revision), (&b"My Service"[..], revision));
js.delete_key_value(&mut connection, "doc_config").await?;
use utopia_nats::key_value::KeyValueConfig;
Rust
pub struct KeyValueConfig

A bucket's configuration.

use utopia_nats::key_value::KeyValueEntry;
Rust
pub struct KeyValueEntry

One revision of a key.

use utopia_nats::key_value::KeyValueStatus;
Rust
pub struct KeyValueStatus

A bucket's size and settings.

use utopia_nats::key_value::KeyValueWatchOptions;
Rust
pub struct KeyValueWatchOptions

What a watch delivers.

use utopia_nats::key_value::KeyValueOperation;
Rust
pub enum KeyValueOperation

What an entry records.

Rust
pub type EntryCallback = Box<dyn FnMut(KeyValueEntry) -> Result<(), CallbackError> + Send>

A callback receiving watched entries.

Rust
pub type InitCallback = Box<dyn FnMut() -> Result<(), CallbackError> + Send>

Called once the initial set of a watch was delivered.