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>
pub async fn checkpoint(&self) -> KanbanResult<()>
Trait Implementations§
Source§impl CommandStore for SqliteStore
impl CommandStore for SqliteStore
Source§fn append_commands(&self, cmds: &[Command]) -> KanbanResult<u64>
fn append_commands(&self, cmds: &[Command]) -> KanbanResult<u64>
Appends a batch of commands as one undo unit. Returns the new logical
batch count (which equals the new cursor position after execute).
Source§fn command_count(&self) -> KanbanResult<u64>
fn command_count(&self) -> KanbanResult<u64>
Returns the number of batches currently stored (logical count).
Source§fn load_commands(&self, from: u64, to: u64) -> KanbanResult<Vec<Vec<Command>>>
fn load_commands(&self, from: u64, to: u64) -> KanbanResult<Vec<Vec<Command>>>
Returns batches in the half-open logical range
[from, to).
from is 0-indexed; to is exclusive.Source§fn load_all_commands(&self) -> KanbanResult<(Vec<Vec<Command>>, u64)>
fn load_all_commands(&self) -> KanbanResult<(Vec<Vec<Command>>, u64)>
Atomically loads all command batches and the count.
Default implementation calls
command_count() then load_commands(),
which is not atomic. Backends with interior locks should override.Source§fn truncate_commands_after(&self, after: u64) -> KanbanResult<()>
fn truncate_commands_after(&self, after: u64) -> KanbanResult<()>
Removes all batches with index >= after (i.e. retains batches 0..after).
Source§fn supports_indexed_snapshots(&self) -> bool
fn supports_indexed_snapshots(&self) -> bool
Whether this store supports O(1) snapshot lookup at a given command index.
When true,
undo()/redo() load a stored snapshot instead of replaying.Source§fn store_snapshot_at(&self, idx: u64, snapshot: &Snapshot) -> KanbanResult<()>
fn store_snapshot_at(&self, idx: u64, snapshot: &Snapshot) -> KanbanResult<()>
Stores a snapshot associated with command index
idx.Source§fn shift_commands(&self, drop_count: u64) -> KanbanResult<()>
fn shift_commands(&self, drop_count: u64) -> KanbanResult<()>
Removes the oldest
drop_count batches and renumbers the remaining
batches so they start from index 0. Also removes any indexed snapshots
for dropped batches and renumbers surviving ones.Source§fn load_snapshot_at(&self, idx: u64) -> KanbanResult<Option<Snapshot>>
fn load_snapshot_at(&self, idx: u64) -> KanbanResult<Option<Snapshot>>
Loads the snapshot stored at command index
idx, if any.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>>
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<()>
Atomically read-modify-write the dependency graph. Read more
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,
Save a snapshot to the store
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,
Load the current snapshot from the store
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,
Check if the store file exists
Source§fn instance_id(&self) -> Uuid
fn instance_id(&self) -> Uuid
Get the unique instance ID for this store
Source§fn sync_command_log<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_batches: &'life1 [Vec<Command>],
_cursor: u64,
_baseline: Option<&'life2 [u8]>,
) -> Pin<Box<dyn Future<Output = Result<(), PersistenceError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn sync_command_log<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_batches: &'life1 [Vec<Command>],
_cursor: u64,
_baseline: Option<&'life2 [u8]>,
) -> Pin<Box<dyn Future<Output = Result<(), PersistenceError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Sync the command log from the in-memory backend to persistent storage.
Default implementation is a no-op (SQLite backend writes directly).
Source§fn get_command_log(
&self,
) -> Result<(Vec<Vec<Command>>, u64, Option<Vec<u8>>), PersistenceError>
fn get_command_log( &self, ) -> Result<(Vec<Vec<Command>>, u64, Option<Vec<u8>>), PersistenceError>
Retrieve the command log, undo cursor, and optional baseline snapshot.
Returns
(batches, cursor, baseline_bytes). Default returns empty.Source§fn load_sync(
&self,
) -> Result<Option<(StoreSnapshot, PersistenceMetadata)>, PersistenceError>
fn load_sync( &self, ) -> Result<Option<(StoreSnapshot, PersistenceMetadata)>, PersistenceError>
Load the store synchronously (no async runtime required).
Returns
Ok(None) when the backing file does not exist. Read moreAuto Trait Implementations§
impl Freeze for SqliteStore
impl !RefUnwindSafe for SqliteStore
impl Send for SqliteStore
impl Sync for SqliteStore
impl Unpin for SqliteStore
impl UnsafeUnpin for SqliteStore
impl !UnwindSafe 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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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