pub struct SqliteStore { /* private fields */ }Expand description
SQLite-backed persistence store using sqlx connection pool.
Implementations§
Source§impl SqliteStore
impl SqliteStore
pub async fn open(path: impl AsRef<Path>) -> KanbanResult<Self>
pub fn pool(&self) -> &Pool<Sqlite>
Sourcepub fn read_metadata_sync(&self) -> KanbanResult<Option<PersistenceMetadata>>
pub fn read_metadata_sync(&self) -> KanbanResult<Option<PersistenceMetadata>>
Read the metadata singleton row from the DB. Cheap (single row, indexed by primary key).
Returns Ok(None) if the row is absent — only possible on a brand-new DB
before load_or_create_instance_id has run, which the public API doesn’t expose.
Sourcepub async fn stamp_writer(&self) -> KanbanResult<DateTime<Utc>>
pub async fn stamp_writer(&self) -> KanbanResult<DateTime<Utc>>
Record the current binary as the most-recent writer of this DB by
stamping saved_at, writer_version, and writer_commit into the
metadata singleton row. Returns the timestamp it wrote so callers can
echo it back into a PersistenceMetadata without re-reading the row.
Separated from [checkpoint] so each function does one thing — see
the post-PR-288 review for the SRP rationale.
Sourcepub async fn checkpoint(&self) -> KanbanResult<()>
pub async fn checkpoint(&self) -> KanbanResult<()>
Truncate the WAL. Pure I/O step; does not touch the writer-stamp
columns. Callers that want a durable save with attribution should
invoke [stamp_writer] alongside this.
Sourcepub async fn append_command_batch(
&self,
batch_index: u64,
commands_json: &str,
) -> KanbanResult<()>
pub async fn append_command_batch( &self, batch_index: u64, commands_json: &str, ) -> KanbanResult<()>
Append a single command batch at logical index batch_index.
commands_json is the serde-JSON encoding of the Vec<Command> batch.
Sourcepub async fn load_all_command_batches(&self) -> KanbanResult<Vec<String>>
pub async fn load_all_command_batches(&self) -> KanbanResult<Vec<String>>
Load all persisted command batches in order. Returns the JSON strings so callers can deserialise inside the domain layer.
Sourcepub async fn truncate_command_log_after(&self, after: u64) -> KanbanResult<()>
pub async fn truncate_command_log_after(&self, after: u64) -> KanbanResult<()>
Remove batches with logical index >= after. Retains [0, after).
Sourcepub async fn shift_command_log(&self, drop_count: u64) -> KanbanResult<()>
pub async fn shift_command_log(&self, drop_count: u64) -> KanbanResult<()>
Remove the oldest drop_count batches and renumber the rest so the
surviving log starts at index 0.
Trait Implementations§
Source§impl DataStore for SqliteStore
impl DataStore for SqliteStore
fn get_board(&self, id: Uuid) -> KanbanResult<Option<Board>>
fn list_boards(&self) -> KanbanResult<Vec<Board>>
fn upsert_board(&self, board: Board) -> KanbanResult<()>
fn delete_board(&self, id: Uuid) -> KanbanResult<()>
fn get_column(&self, id: Uuid) -> KanbanResult<Option<Column>>
fn list_columns_by_board(&self, board_id: Uuid) -> KanbanResult<Vec<Column>>
fn list_all_columns(&self) -> KanbanResult<Vec<Column>>
fn upsert_column(&self, column: Column) -> KanbanResult<()>
fn delete_column(&self, id: Uuid) -> KanbanResult<()>
fn delete_columns_by_board(&self, board_id: Uuid) -> KanbanResult<()>
fn get_card(&self, id: Uuid) -> KanbanResult<Option<Card>>
fn list_all_cards(&self) -> KanbanResult<Vec<Card>>
fn list_cards_by_column(&self, column_id: Uuid) -> KanbanResult<Vec<Card>>
Source§fn list_cards_by_columns(&self, column_ids: &[Uuid]) -> KanbanResult<Vec<Card>>
fn list_cards_by_columns(&self, column_ids: &[Uuid]) -> KanbanResult<Vec<Card>>
fn list_cards_by_sprint(&self, sprint_id: Uuid) -> KanbanResult<Vec<Card>>
fn count_cards_in_column(&self, column_id: Uuid) -> KanbanResult<usize>
fn count_cards_in_column_excluding( &self, column_id: Uuid, exclude: &[Uuid], ) -> KanbanResult<usize>
fn upsert_card(&self, card: Card) -> KanbanResult<()>
fn delete_card(&self, id: Uuid) -> KanbanResult<()>
fn delete_cards_by_columns(&self, column_ids: &[Uuid]) -> KanbanResult<()>
fn clear_sprint_from_cards( &self, sprint_id: Uuid, timestamp: DateTime<Utc>, ) -> KanbanResult<()>
fn get_archived_card(&self, card_id: Uuid) -> KanbanResult<Option<ArchivedCard>>
fn list_archived_cards(&self) -> KanbanResult<Vec<ArchivedCard>>
fn insert_archived_card(&self, ac: ArchivedCard) -> KanbanResult<()>
fn delete_archived_card(&self, card_id: Uuid) -> KanbanResult<()>
fn list_archived_cards_by_columns( &self, column_ids: &[Uuid], ) -> KanbanResult<Vec<ArchivedCard>>
fn clear_sprint_from_archived_cards( &self, sprint_id: Uuid, timestamp: DateTime<Utc>, ) -> KanbanResult<()>
fn get_sprint(&self, id: Uuid) -> KanbanResult<Option<Sprint>>
fn list_sprints_by_board(&self, board_id: Uuid) -> KanbanResult<Vec<Sprint>>
fn list_all_sprints(&self) -> KanbanResult<Vec<Sprint>>
fn upsert_sprint(&self, sprint: Sprint) -> KanbanResult<()>
fn delete_sprint(&self, id: Uuid) -> KanbanResult<()>
fn delete_sprints_by_board(&self, board_id: Uuid) -> KanbanResult<()>
fn get_graph(&self) -> KanbanResult<DependencyGraph>
fn set_graph(&self, graph: DependencyGraph) -> KanbanResult<()>
Source§fn modify_graph(&self, f: GraphMutFn) -> KanbanResult<()>
fn modify_graph(&self, f: GraphMutFn) -> KanbanResult<()>
fn snapshot(&self) -> KanbanResult<Snapshot>
fn apply_snapshot(&self, snapshot: Snapshot) -> KanbanResult<()>
Source§impl PersistenceStore for SqliteStore
impl PersistenceStore for SqliteStore
Source§fn save<'life0, 'async_trait>(
&'life0 self,
snapshot: StoreSnapshot,
) -> Pin<Box<dyn Future<Output = PersistenceResult<PersistenceMetadata>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn save<'life0, 'async_trait>(
&'life0 self,
snapshot: StoreSnapshot,
) -> Pin<Box<dyn Future<Output = PersistenceResult<PersistenceMetadata>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn load<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = PersistenceResult<(StoreSnapshot, PersistenceMetadata)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn load<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = PersistenceResult<(StoreSnapshot, PersistenceMetadata)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn exists<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn exists<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn instance_id(&self) -> Uuid
fn instance_id(&self) -> Uuid
Source§fn close<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn close<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
sqlx pool)
outlive synchronous Drop because the runtime needs time to close
each connection. Read moreSource§fn load_sync(
&self,
) -> Result<Option<(StoreSnapshot, PersistenceMetadata)>, PersistenceError>
fn load_sync( &self, ) -> Result<Option<(StoreSnapshot, PersistenceMetadata)>, PersistenceError>
Ok(None) when the backing file does not exist. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for SqliteStore
impl !UnwindSafe for SqliteStore
impl Freeze for SqliteStore
impl Send for SqliteStore
impl Sync for SqliteStore
impl Unpin for SqliteStore
impl UnsafeUnpin for SqliteStore
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more