pub struct LedgerStore { /* private fields */ }Expand description
Persistence for ledger records under {data_dir}/ledger/v1.
Implementations§
Source§impl LedgerStore
impl LedgerStore
pub fn new(data_dir: impl Into<PathBuf>) -> Self
pub fn with_defaults() -> Self
pub fn resolver(&self) -> &LedgerPathResolver
Sourcepub async fn write_record(
&self,
record: LedgerRecord,
body: Option<String>,
) -> Result<LedgerRecordDocument>
pub async fn write_record( &self, record: LedgerRecord, body: Option<String>, ) -> Result<LedgerRecordDocument>
Create or replace a record document. Preserves created_at (and the
body, when body is None) of an existing record with the same id;
always bumps updated_at.
pub async fn get_record( &self, scope: LedgerScope, project_key: Option<&str>, record_id: &str, ) -> Result<Option<LedgerRecordDocument>>
Sourcepub async fn transition_record(
&self,
scope: LedgerScope,
project_key: Option<&str>,
record_id: &str,
status: RecordStatus,
reason: Option<&str>,
) -> Result<Option<LedgerRecordDocument>>
pub async fn transition_record( &self, scope: LedgerScope, project_key: Option<&str>, record_id: &str, status: RecordStatus, reason: Option<&str>, ) -> Result<Option<LedgerRecordDocument>>
Transition a record’s status (recording history) and refresh artifacts.
Returns the updated document, or None when either the record does not
exist or the status is already the target (no-op).
Sourcepub async fn list_records(
&self,
scope: LedgerScope,
project_key: Option<&str>,
filter: &RecordFilter,
) -> Result<Vec<LedgerRecordDocument>>
pub async fn list_records( &self, scope: LedgerScope, project_key: Option<&str>, filter: &RecordFilter, ) -> Result<Vec<LedgerRecordDocument>>
Load and filter a scope’s records, anchored records first (ascending), undated records after (most recently updated first).
Sourcepub async fn agenda(
&self,
scopes: &[(LedgerScope, Option<String>)],
now: DateTime<Utc>,
horizon_days: i64,
) -> Result<AgendaSnapshot>
pub async fn agenda( &self, scopes: &[(LedgerScope, Option<String>)], now: DateTime<Utc>, horizon_days: i64, ) -> Result<AgendaSnapshot>
Build a time-bucketed agenda across one or more scopes (typically the global scope plus the current project’s).
Sourcepub async fn read_time_index(
&self,
scope: LedgerScope,
project_key: Option<&str>,
) -> Result<Option<TimeIndex>>
pub async fn read_time_index( &self, scope: LedgerScope, project_key: Option<&str>, ) -> Result<Option<TimeIndex>>
Cheap agenda read for the prompt layer: derived purely from
by_time.json plus the undated slice of by_status.json would lose
priority ordering, so today it re-reads records; scale is human-sized.
Sourcepub async fn list_project_keys(&self) -> Result<Vec<String>>
pub async fn list_project_keys(&self) -> Result<Vec<String>>
Project keys that have a ledger scope directory on disk — the iteration surface for background maintenance across every scope.
Sourcepub async fn rebuild_scope(
&self,
scope: LedgerScope,
project_key: Option<&str>,
) -> Result<()>
pub async fn rebuild_scope( &self, scope: LedgerScope, project_key: Option<&str>, ) -> Result<()>
Rebuild every derived artifact for a scope from the record documents.
Trait Implementations§
Source§impl Clone for LedgerStore
impl Clone for LedgerStore
Source§fn clone(&self) -> LedgerStore
fn clone(&self) -> LedgerStore
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more