egui Persistence: Save & Restore Settings with serde | Rust GUI Ep 23
4views
009:09
T
Taught by Celeste AI - AI Coding Coach
View on YouTubeDescription
Build a Settings App that saves and restores preferences across restarts using eframe persistence and serde serialization! Learn get_value(),
set_value(), the save() method, and the persistence feature flag.
Student code: https://github.com/GoCelesteAI/egui_persistence/tree/main
What You'll Learn:
- #[derive(Serialize, Deserialize)] to make app state serializable
- eframe::get_value() to load saved state from storage
- eframe::set_value() to save state to storage
- fn save(&mut self, storage) method on the App trait
- eframe::APP_KEY as the default storage key
- CreationContext for initialization with saved data
- persistence feature flag in Cargo.toml
- Dark/light theme toggle with ctx.set_visuals()
- Slider and checkbox settings with Grid layout
- Reset to defaults pattern
Timestamps:
0:00 Intro
0:12 App Preview
0:22 What We're Building
0:54 Create Project & Cargo.toml (persistence + serde)
1:18 main.rs — CreationContext with MyApp::new(cc)
1:52 app.rs — Imports & serde Derive
2:18 MyApp Struct with Serializable Fields
2:34 Default Implementation
3:12 new() Constructor — Loading from Storage
3:52 impl App — save() with set_value
4:16 update() — Dark/Light Theme Toggle
4:58 Settings Grid — Username, Checkboxes, Sliders
6:18 Reset to Defaults Button
6:32 cargo build & Neo-tree H (Hidden Files)
7:00 App Demo (Close & Reopen to Verify Persistence)
7:54 Recap
8:34 Next Episode
Series: Learn egui in Neovim
Part of a 36-episode series teaching Rust GUI development with egui, coded entirely in Neovim with Neo-tree.
Tags: egui, rust, gui, persistence, serde, serialize, storage, tutorial, neovim, settings app, save state, get_value, set_value, eframe
Tags
eguirustguipersistenceserdeserializestoragetutorialneovimsettings appsave stateget_valueset_valueeframe