#tauri-plugin-store: how do I get() inside with_store() on the rust side?

4 messages · Page 1 of 1 (latest)

odd snow
#

Hi,

I'm trying to implement a persistent storage for app data and I've found tauri-plugin-store.
To share data storage between JS and Rust there's a shared 'store' which on the rust side is accessible with the function with_store().

I can't figure out how to retrieve and use a value from the store.

Right now, I'm trying something like what is attached as a screenshot.

The output of dbg!() is
[src/main.rs:235] k = ""23""

but I want just the value '23'

I have two questions

  1. My process of getting the value from the store feels wrong in some way. I can't find any documentation on how to use get() inside with_store() and my solution with and_then() including Some() and ok_or() just feels wrong.
  2. Even if my solution to extract a value of some key is appropriate, how do I convert it to just '23'?
tropic atlas
#

Replace and_then with map (which will also result in the removal of the Some wrapping the value).

Is the value in your store 23 a number or "23" a string?

timid warren
odd snow
#

Thanks guys! This helped me 🙂