Skip to main content

ThreadManager

Struct ThreadManager 

Source
pub struct ThreadManager { /* private fields */ }

Implementations§

Source§

impl ThreadManager

Source

pub fn new(heddle_dir: &Path) -> Self

Source

pub fn save(&self, thread: &Thread) -> Result<()>

Source

pub fn load(&self, thread_id: &str) -> Result<Option<Thread>>

Source

pub fn list(&self) -> Result<Vec<Thread>>

Source

pub fn find_by_thread(&self, thread: &str) -> Result<Option<Thread>>

Source

pub fn find_by_execution_root(&self, root: &Path) -> Result<Option<Thread>>

Source

pub fn delete(&self, thread_id: &str) -> Result<()>

Source

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.

Source

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.

Source

pub fn load_record(&self, record_id: &str) -> Result<Option<ThreadRecord>>

Source

pub fn save_record(&self, record: &ThreadRecord) -> Result<()>

Source

pub fn list_records(&self) -> Result<Vec<ThreadRecord>>

Source

pub fn find_record_by_thread( &self, thread: &str, ) -> Result<Option<ThreadRecord>>

Source

pub fn find_synced_record_by_thread( &self, repo: &Repository, thread: &str, current_state_override: Option<StateId>, ) -> Result<Option<SyncedThreadMetadata>>

Source

pub fn delete_record(&self, record_id: &str) -> Result<()>

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> ThreadManager

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ThreadManager

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more