worker-kv

Docs.rs Crates.io Unlicense

Rust bindings to Cloudflare Worker KV Stores using wasm-bindgen and js-sys.

Example

```rust let kv = KvStore::create("Example")?;

// Insert a new entry into the kv. kv.put("examplekey", "examplevalue") .metadata(vec![1, 2, 3, 4]) // Use some arbitrary serialiazable metadata .execute() .await?;

// NOTE: kv changes can take a minute to become visible to other workers. // Get that same metadata. let (value, metdata) = kv.getwithmetadata::>("example_key").await?; ```

For a more complete example check out the full example.

How do I use futures in WebAssembly?

There currently is not a way to use a Future natively from WebAssembly but with the futuretopromise function from wasmbindgenfutures we can convert it to a standard JavaScript promise, which can be awaited in the regular JavaScript context.