pub struct LocalDb { /* private fields */ }Expand description
Local SQLite database shared by TUI and Daemon.
Thread-safe: wraps the connection in a Mutex so it can be shared via Arc<LocalDb>.
Implementations§
Source§impl LocalDb
impl LocalDb
Sourcepub fn open() -> Result<Self>
pub fn open() -> Result<Self>
Open (or create) the local database at the default path.
~/.local/share/opensession/local.db
Sourcepub fn open_path(path: &PathBuf) -> Result<Self>
pub fn open_path(path: &PathBuf) -> Result<Self>
Open (or create) the local database at a specific path.
pub fn upsert_local_session( &self, session: &Session, source_path: &str, git: &GitContext, ) -> Result<()>
pub fn upsert_remote_session(&self, summary: &SessionSummary) -> Result<()>
pub fn list_sessions( &self, filter: &LocalSessionFilter, ) -> Result<Vec<LocalSessionRow>>
pub fn get_sync_cursor(&self, team_id: &str) -> Result<Option<String>>
pub fn set_sync_cursor(&self, team_id: &str, cursor: &str) -> Result<()>
Sourcepub fn pending_uploads(&self, team_id: &str) -> Result<Vec<LocalSessionRow>>
pub fn pending_uploads(&self, team_id: &str) -> Result<Vec<LocalSessionRow>>
Get sessions that are local_only and need to be uploaded.
pub fn mark_synced(&self, session_id: &str) -> Result<()>
Sourcepub fn was_uploaded_after(
&self,
source_path: &str,
modified: &DateTime<Utc>,
) -> Result<bool>
pub fn was_uploaded_after( &self, source_path: &str, modified: &DateTime<Utc>, ) -> Result<bool>
Check if a session was already uploaded (synced or remote_only) since the given modification time.
pub fn cache_body(&self, session_id: &str, body: &[u8]) -> Result<()>
pub fn get_cached_body(&self, session_id: &str) -> Result<Option<Vec<u8>>>
Sourcepub fn migrate_from_state_json(
&self,
uploaded: &HashMap<String, DateTime<Utc>>,
) -> Result<usize>
pub fn migrate_from_state_json( &self, uploaded: &HashMap<String, DateTime<Utc>>, ) -> Result<usize>
Migrate entries from the old state.json UploadState into the local DB.
Marks them as synced with no metadata (we only know the file path was uploaded).
Sourcepub fn list_repos(&self) -> Result<Vec<String>>
pub fn list_repos(&self) -> Result<Vec<String>>
Get a list of distinct git repo names present in the DB.
Auto Trait Implementations§
impl !Freeze for LocalDb
impl RefUnwindSafe for LocalDb
impl Send for LocalDb
impl Sync for LocalDb
impl Unpin for LocalDb
impl UnwindSafe for LocalDb
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