State management for Rust GUI apps — persistence, reactivity, and migrations without the boilerplate.
Developer toolsRust · JavaScriptGitHub @guinea-rsOnlineOwner unconfirmed
Have you tried it? One tap is enough. No sign-in needed.
Type-safe state-manager for Rust GUI apps.
Translation pending
Taken from the repository README
Loading the full README. The saved excerpt is shown below.
A state manager for Rust applications.
amethystate is a state manager for Rust applications: state is declared as an ordinary struct, its fields are
reactive, and they outlive the program.Read the full README ↗A state manager for Rust applications.
amethystate manages persistent, reactive state for Rust applications.
Declare your settings as a struct, read and update them through field handles,
and subscribe to changes. The library saves the values between runs.
Open implementation for checks involving several fields.Kv when the keys are not known at compile time.durable() on a field, map or Kv path when a write must reach disk before returning.localStorage and receive changes from other tabs.[!WARNING] About half of the engines are not used in any real application. They are covered by CI and smoke tests, but that is not a substitute for use in an application. Expect rough edges and report problems you find.
use amethystate::{StoreBuilder, amethystate};
#[amethystate(prefix = "network")]
pub struct NetworkState {
#[amestate(default = "127.0.0.1".to_string())]
pub host: String,
#[amestate(default = 8080u16)]
pub port: u16,
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
let store = StoreBuilder::new("./app").build()?;
let state = NetworkState::new_with(&store);
let _sub = state.port().subscribe(|port| println!("port → {port}"));
state.port().set(9090);
Ok(())
}
See the book for full documentation — concepts, the store, and migrations.
Before writing code against amethystate, read AGENTS.md and the relevant book sections. The book explains when to use each API and the trade-offs that are not visible in its signature.
The minimum supported Rust version (MSRV) for amethystate is 1.90.
Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.