Add async session persistence helpers for save/load state#112
Merged
ryanoneill merged 3 commits intomainfrom Mar 2, 2026
Merged
Add async session persistence helpers for save/load state#112ryanoneill merged 3 commits intomainfrom
ryanoneill merged 3 commits intomainfrom
Conversation
Add load_state<S>(path) function that reads a JSON file and deserializes into any DeserializeOwned type. Add Command::save_state() that serializes state to JSON and writes to disk. Both behind the serialization feature flag. Uses structured EnvisionError::Config variant for deserialization errors. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add tokio "fs" feature to enable tokio::fs::write for async file I/O in Command::save_state. File write errors are reported to the runtime's error channel via try_perform_async. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
load_state now uses tokio::fs::read_to_string for non-blocking file I/O, consistent with save_state's use of tokio::fs::write. All persistence tests updated to #[tokio::test]. Added tokio-test dev-dependency for async doc test support. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #112 +/- ##
==========================================
- Coverage 92.66% 92.61% -0.06%
==========================================
Files 99 100 +1
Lines 9517 9530 +13
==========================================
+ Hits 8819 8826 +7
- Misses 698 704 +6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
load_state<S: DeserializeOwned>(path)usingtokio::fs::read_to_stringfor non-blocking file I/OCommand::save_state<S: Serialize>(state, path)usingtokio::fs::writefor async file writes#[cfg(feature = "serialization")]EnvisionError::Config { field, reason }variant for deserialization errors"fs"feature andtokio-testdev-dependencyenvision::app::persistenceandenvision::app::load_stateReplaces #111.
Test plan
cargo test— all tests pass (6 async persistence tests)cargo clippy -- -D warnings— cleancargo check --no-default-features— compilescargo test --doc— 276 doc tests passcargo build --examples— compiles🤖 Generated with Claude Code