pub trait ScratchStore {
// Required methods
fn write_entry(
&self,
ref_name: &str,
entry: &ScratchEntry,
agent_id: &str,
) -> Result<ScratchEntry>;
fn read_entry(
&self,
ref_name: &str,
scratch_id: &str,
) -> Result<ScratchEntry>;
fn update_entry(
&self,
ref_name: &str,
scratch_id: &str,
content: &str,
agent_id: &str,
) -> Result<ScratchEntry>;
fn list_entries(
&self,
ref_name: &str,
filter: &ScratchFilter,
) -> Result<Vec<ScratchEntry>>;
fn discard_entry(
&self,
ref_name: &str,
scratch_id: &str,
agent_id: &str,
) -> Result<()>;
fn mark_promoted(
&self,
ref_name: &str,
scratch_id: &str,
ledger_entry_id: &str,
agent_id: &str,
) -> Result<ScratchEntry>;
fn clean_entries(
&self,
ref_name: &str,
filter: &CleanFilter,
dry_run: bool,
) -> Result<usize>;
}Expand description
Scratch-entry CRUD operations.
All methods are direct (no policy gate). Only mark_promoted is expected
to be called after the caller has already created a [LedgerEntry] via
the policy-gated ledger store.
Required Methods§
Sourcefn write_entry(
&self,
ref_name: &str,
entry: &ScratchEntry,
agent_id: &str,
) -> Result<ScratchEntry>
fn write_entry( &self, ref_name: &str, entry: &ScratchEntry, agent_id: &str, ) -> Result<ScratchEntry>
Persist a new scratch entry. Returns the stored entry (may have
updated_at refreshed by the impl).
Sourcefn read_entry(&self, ref_name: &str, scratch_id: &str) -> Result<ScratchEntry>
fn read_entry(&self, ref_name: &str, scratch_id: &str) -> Result<ScratchEntry>
Read a single entry by scratch_id.
Sourcefn update_entry(
&self,
ref_name: &str,
scratch_id: &str,
content: &str,
agent_id: &str,
) -> Result<ScratchEntry>
fn update_entry( &self, ref_name: &str, scratch_id: &str, content: &str, agent_id: &str, ) -> Result<ScratchEntry>
Replace the content of an existing draft entry and refresh updated_at.
Sourcefn list_entries(
&self,
ref_name: &str,
filter: &ScratchFilter,
) -> Result<Vec<ScratchEntry>>
fn list_entries( &self, ref_name: &str, filter: &ScratchFilter, ) -> Result<Vec<ScratchEntry>>
List entries matching the filter, newest first.
Sourcefn discard_entry(
&self,
ref_name: &str,
scratch_id: &str,
agent_id: &str,
) -> Result<()>
fn discard_entry( &self, ref_name: &str, scratch_id: &str, agent_id: &str, ) -> Result<()>
Transition status to Discarded. No data is deleted; the entry remains
until clean_entries removes it.
Sourcefn mark_promoted(
&self,
ref_name: &str,
scratch_id: &str,
ledger_entry_id: &str,
agent_id: &str,
) -> Result<ScratchEntry>
fn mark_promoted( &self, ref_name: &str, scratch_id: &str, ledger_entry_id: &str, agent_id: &str, ) -> Result<ScratchEntry>
Transition status to Promoted and record which ledger entry it became.
The caller is responsible for creating the ledger entry first.
Sourcefn clean_entries(
&self,
ref_name: &str,
filter: &CleanFilter,
dry_run: bool,
) -> Result<usize>
fn clean_entries( &self, ref_name: &str, filter: &CleanFilter, dry_run: bool, ) -> Result<usize>
Permanently delete entries matching the filter. Returns the number
of entries removed (0 when dry_run is true).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".