host: read_json takes the runtime as impl Runtime so callers can name only T
read_json::<T>(app, name) did not compile with two explicit generic parameters; the app's call sites name only the value type. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
41267a22fd
commit
b13d9acf14
1 changed files with 2 additions and 1 deletions
|
|
@ -59,7 +59,8 @@ pub fn data_file<R: Runtime>(app: &AppHandle<R>, name: &str) -> Option<std::path
|
|||
app.path().app_data_dir().ok().map(|dir| dir.join(name))
|
||||
}
|
||||
|
||||
pub fn read_json<R: Runtime, T: serde::de::DeserializeOwned>(app: &AppHandle<R>, name: &str) -> Option<T> {
|
||||
/// `read_json::<T>(app, name)`: the app-data JSON file `name`, or None when missing or invalid.
|
||||
pub fn read_json<T: serde::de::DeserializeOwned>(app: &AppHandle<impl Runtime>, name: &str) -> Option<T> {
|
||||
serde_json::from_str(&std::fs::read_to_string(data_file(app, name)?).ok()?).ok()
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue