hinge_rs/api/
persistence.rs1use crate::client::HingeClient;
2use crate::errors::HingeError;
3use crate::storage::Storage;
4use std::path::PathBuf;
5
6pub struct PersistenceApi<'a, S: Storage + Clone> {
7 pub(super) client: &'a mut HingeClient<S>,
8}
9
10impl<S: Storage + Clone> PersistenceApi<'_, S> {
11 pub fn save_session(&self, path: &str) -> Result<(), HingeError> {
12 self.client.save_session(path)
13 }
14
15 pub fn load_session(&mut self, path: &str) -> Result<(), HingeError> {
16 self.client.load_session(path)
17 }
18
19 pub fn configure(
20 &mut self,
21 session_path: Option<String>,
22 cache_dir: Option<PathBuf>,
23 auto_persist: bool,
24 ) {
25 let cloned = self.client.clone();
26 *self.client = cloned.with_persistence(session_path, cache_dir, auto_persist);
27 }
28}