Skip to main content

LocalDb

Struct LocalDb 

Source
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

Source

pub fn open() -> Result<Self>

Open (or create) the local database at the default path. ~/.local/share/opensession/local.db

Source

pub fn open_path(path: &PathBuf) -> Result<Self>

Open (or create) the local database at a specific path.

Source

pub fn upsert_local_session( &self, session: &Session, source_path: &str, git: &GitContext, ) -> Result<()>

Source

pub fn upsert_remote_session(&self, summary: &SessionSummary) -> Result<()>

Source

pub fn list_sessions( &self, filter: &LocalSessionFilter, ) -> Result<Vec<LocalSessionRow>>

Source

pub fn get_sync_cursor(&self, team_id: &str) -> Result<Option<String>>

Source

pub fn set_sync_cursor(&self, team_id: &str, cursor: &str) -> Result<()>

Source

pub fn pending_uploads(&self, team_id: &str) -> Result<Vec<LocalSessionRow>>

Get sessions that are local_only and need to be uploaded.

Source

pub fn mark_synced(&self, session_id: &str) -> Result<()>

Source

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.

Source

pub fn cache_body(&self, session_id: &str, body: &[u8]) -> Result<()>

Source

pub fn get_cached_body(&self, session_id: &str) -> Result<Option<Vec<u8>>>

Source

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).

Source

pub fn list_repos(&self) -> Result<Vec<String>>

Get a list of distinct git repo names present in the DB.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.