pub struct ThreadManager { /* private fields */ }Implementations§
Source§impl ThreadManager
impl ThreadManager
pub fn new(heddle_dir: &Path) -> Self
pub fn save(&self, thread: &Thread) -> Result<()>
pub fn load(&self, thread_id: &str) -> Result<Option<Thread>>
pub fn list(&self) -> Result<Vec<Thread>>
pub fn find_by_thread(&self, thread: &str) -> Result<Option<Thread>>
pub fn find_by_execution_root(&self, root: &Path) -> Result<Option<Thread>>
pub fn delete(&self, thread_id: &str) -> Result<()>
Sourcepub fn converge_records(&self, name: &str, desired: &[Thread]) -> Result<()>
pub fn converge_records(&self, name: &str, desired: &[Thread]) -> Result<()>
Converge the persisted record set for thread name to EXACTLY desired
(by record id), atomically under a single write lock: delete every record
filed under name whose id is not in desired, then save every record in
desired. Post-condition: { records with .thread == name } has exactly
the id-set of desired, so find_by_thread
returns one of desired REGARDLESS of what (possibly unknown-id,
newer-timestamped) record a rolled-back or duplicating forward left behind
— the leaked record’s id never has to be known, because every non-desired
record under the name is dropped.
This is the SOLE lock-atomic mutation point for a thread’s record set: every undo/redo thread-record convergence (save, redo-restore, undo-remove) routes through it, so there is one chokepoint, not a per-path collection of save/delete sequences each racing a concurrent same-name writer.
Sourcepub fn snapshot_records(&self, name: &str) -> Result<Vec<Thread>>
pub fn snapshot_records(&self, name: &str) -> Result<Vec<Thread>>
Snapshot every record currently filed under name (lock-atomic), hydrated
with its workspace half, for registering a converge-back inverse. Pairs
with converge_records: capture the full prior
same-name set with this, and converge_records(name, &prior) restores it
exactly on rollback.
pub fn load_record(&self, record_id: &str) -> Result<Option<ThreadRecord>>
pub fn save_record(&self, record: &ThreadRecord) -> Result<()>
pub fn list_records(&self) -> Result<Vec<ThreadRecord>>
pub fn find_record_by_thread( &self, thread: &str, ) -> Result<Option<ThreadRecord>>
pub fn find_synced_record_by_thread( &self, repo: &Repository, thread: &str, current_state_override: Option<StateId>, ) -> Result<Option<SyncedThreadMetadata>>
pub fn delete_record(&self, record_id: &str) -> Result<()>
Sourcepub fn snapshot_thread_record(
&self,
thread_name: &str,
) -> Result<Option<Vec<u8>>>
pub fn snapshot_thread_record( &self, thread_name: &str, ) -> Result<Option<Vec<u8>>>
Encode the Thread record matching thread_name to opaque
rmp-serde bytes for inclusion in OpRecord::ThreadCreate’s
manager_snapshot field. Returns Ok(None) when no record
exists for that thread (the caller doesn’t have a record to
snapshot — e.g. cmd_start --path writes the record only after
materialization, and the rename batch’s new-name arm never has
one). heddle#23 r2.
The encoding is opaque to the oplog crate: it stores the bytes
without interpreting them. The shape is Thread’s serde form,
which has #[serde(default)] on every optional field, so
records written by future versions of heddle remain decodable
by older readers and vice versa.
Sourcepub fn encode_thread_record_snapshot(&self, thread: &Thread) -> Result<Vec<u8>>
pub fn encode_thread_record_snapshot(&self, thread: &Thread) -> Result<Vec<u8>>
Encode a concrete Thread record using the same opaque snapshot format
as snapshot_thread_record.
Sourcepub fn decode_thread_record_snapshot(&self, bytes: &[u8]) -> Result<Thread>
pub fn decode_thread_record_snapshot(&self, bytes: &[u8]) -> Result<Thread>
Decode a Thread record from rmp-serde bytes produced by
snapshot_thread_record. Used by heddle undo --redo of a
ThreadCreate to reconstruct the record body that undo destroyed
(heddle#23 r2 Codex P1, mirroring the FastForward pattern from
heddle#99 r2 — record what redo needs).
Decode ONLY — it does NOT persist. The redo applier converges the
decoded record onto the thread’s record set via
converge_records, so the restore writes the
record as the SOLE record under the name (a raw save would leave a
pre-existing duplicate behind). An invalid snapshot surfaces as
HeddleError::Serialization — the redo arm logs and falls back to
ref-only restore rather than failing the whole batch.
Trait Implementations§
Source§impl Clone for ThreadManager
impl Clone for ThreadManager
Source§fn clone(&self) -> ThreadManager
fn clone(&self) -> ThreadManager
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more