From 99321ddbfac3bcd4156aab769213cfda91d9dad5 Mon Sep 17 00:00:00 2001 From: Tony Date: Mon, 14 Oct 2024 20:34:43 +0800 Subject: [PATCH] Remove StoreInner from pub and expose is_empty --- plugins/store/src/lib.rs | 2 +- plugins/store/src/store.rs | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/plugins/store/src/lib.rs b/plugins/store/src/lib.rs index dbc35093..5eecf8d7 100644 --- a/plugins/store/src/lib.rs +++ b/plugins/store/src/lib.rs @@ -21,7 +21,7 @@ use std::{ sync::{Arc, Mutex}, time::Duration, }; -pub use store::{resolve_store_path, DeserializeFn, SerializeFn, Store, StoreBuilder, StoreInner}; +pub use store::{resolve_store_path, DeserializeFn, SerializeFn, Store, StoreBuilder}; use tauri::{ plugin::{self, TauriPlugin}, AppHandle, Manager, ResourceId, RunEvent, Runtime, State, diff --git a/plugins/store/src/store.rs b/plugins/store/src/store.rs index e800c99f..30e131ee 100644 --- a/plugins/store/src/store.rs +++ b/plugins/store/src/store.rs @@ -268,7 +268,7 @@ enum AutoSaveMessage { } #[derive(Clone)] -pub struct StoreInner { +struct StoreInner { app: AppHandle, path: PathBuf, cache: HashMap, @@ -515,6 +515,11 @@ impl Store { self.store.lock().unwrap().len() } + /// Returns true if the store contains no elements. + pub fn is_empty(&self) -> bool { + self.store.lock().unwrap().is_empty() + } + /// Update the store from the on-disk state pub fn load(&self) -> crate::Result<()> { self.store.lock().unwrap().load()