pub struct StateApi {
pub prune_throttle: PruneThrottle,
/* private fields */
}Expand description
State management system calls.
All data persistence: file (JSON/Markdown) storage, session management.
Fields§
§prune_throttle: PruneThrottleThrottle for auto-prune to avoid excessive disk scans.
Implementations§
Source§impl StateApi
impl StateApi
Sourcepub fn new(state_store: Arc<StateStore>) -> Self
pub fn new(state_store: Arc<StateStore>) -> Self
Create a new StateApi.
Sourcepub async fn save<T: Serialize>(
&self,
category: &str,
name: &str,
data: &T,
) -> Result<()>
pub async fn save<T: Serialize>( &self, category: &str, name: &str, data: &T, ) -> Result<()>
Save JSON data.
Sourcepub async fn save_markdown(
&self,
category: &str,
name: &str,
content: &str,
) -> Result<()>
pub async fn save_markdown( &self, category: &str, name: &str, content: &str, ) -> Result<()>
Save markdown content.
Sourcepub async fn load<T: DeserializeOwned>(
&self,
category: &str,
name: &str,
) -> Result<Option<T>>
pub async fn load<T: DeserializeOwned>( &self, category: &str, name: &str, ) -> Result<Option<T>>
Load JSON data.
Sourcepub async fn load_markdown(
&self,
category: &str,
name: &str,
) -> Result<Option<String>>
pub async fn load_markdown( &self, category: &str, name: &str, ) -> Result<Option<String>>
Load markdown content.
Sourcepub async fn list_category(&self, category: &str) -> Result<Vec<String>>
pub async fn list_category(&self, category: &str) -> Result<Vec<String>>
List files in a category.
Sourcepub fn commit_all(
&self,
git: &GitLayer,
message: &str,
) -> Result<Option<CommitInfo>>
pub fn commit_all( &self, git: &GitLayer, message: &str, ) -> Result<Option<CommitInfo>>
Commit all changes to git via the provided GitLayer.
Sourcepub async fn save_session(&self, session: &Session) -> Result<()>
pub async fn save_session(&self, session: &Session) -> Result<()>
Save session.
Sourcepub async fn list_sessions(&self) -> Result<Vec<SessionSummary>>
pub async fn list_sessions(&self) -> Result<Vec<SessionSummary>>
List sessions.
Sourcepub async fn delete_session(&self, id: &SessionId) -> Result<bool>
pub async fn delete_session(&self, id: &SessionId) -> Result<bool>
Delete session.
Sourcepub fn workspace_path(&self) -> &Path
pub fn workspace_path(&self) -> &Path
Get workspace base path.
Sourcepub fn store(&self) -> &Arc<StateStore> ⓘ
pub fn store(&self) -> &Arc<StateStore> ⓘ
Access the underlying StateStore (for backup/restore).
Sourcepub async fn prune_sessions(&self, config: &PruneConfig) -> Result<usize>
pub async fn prune_sessions(&self, config: &PruneConfig) -> Result<usize>
Prune sessions based on configuration.
Removes sessions that exceed TTL or exceed the maximum count.
Sourcepub fn should_auto_prune(&self) -> bool
pub fn should_auto_prune(&self) -> bool
Check if auto-prune should run (respects cooldown throttle).
Auto Trait Implementations§
impl !Freeze for StateApi
impl RefUnwindSafe for StateApi
impl Send for StateApi
impl Sync for StateApi
impl Unpin for StateApi
impl UnsafeUnpin for StateApi
impl UnwindSafe for StateApi
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more