Skip to main content

RefBackend

Trait RefBackend 

Source
pub trait RefBackend: CoreRefBackend<Error = HeddleError> {
    // Required methods
    fn get_remote_thread(
        &self,
        remote: &str,
        thread: &ThreadName,
    ) -> Result<Option<StateId>>;
    fn set_remote_thread(
        &self,
        remote: &str,
        thread: &ThreadName,
        state: &StateId,
    ) -> Result<()>;
    fn delete_remote_thread(
        &self,
        remote: &str,
        thread: &ThreadName,
    ) -> Result<Option<StateId>>;
    fn list_remotes(&self) -> Result<Vec<String>>;
    fn list_remote_threads(&self, remote: &str) -> Result<Vec<ThreadName>>;

    // Provided methods
    fn can_commit_records(&self) -> bool { ... }
    fn commit_and_publish(
        &self,
        records: &[OpRecord],
        ref_updates: &[RefUpdate],
        scope: Option<&str>,
    ) -> Result<()> { ... }
    fn inspect_ref_summary_index(&self) -> Result<RefSummaryIndexInspection> { ... }
    fn rebuild_ref_summary_index(&self) -> Result<RefSummaryIndexInspection> { ... }
    fn pack_refs(&self) -> Result<()> { ... }
    fn cleanup_stale_temps(&self) { ... }
}
Expand description

Backend-agnostic interface for reading and writing repository references.

Required Methods§

Source

fn get_remote_thread( &self, remote: &str, thread: &ThreadName, ) -> Result<Option<StateId>>

Source

fn set_remote_thread( &self, remote: &str, thread: &ThreadName, state: &StateId, ) -> Result<()>

Source

fn delete_remote_thread( &self, remote: &str, thread: &ThreadName, ) -> Result<Option<StateId>>

Source

fn list_remotes(&self) -> Result<Vec<String>>

Source

fn list_remote_threads(&self, remote: &str) -> Result<Vec<ThreadName>>

Provided Methods§

Source

fn can_commit_records(&self) -> bool

Whether this backend can durably commit a non-empty operation record batch at the commit_and_publish seam.

Recordless/bootstrap backends still route ref batches through the same chokepoint, but callers must pass an empty record batch. The default is conservative so an unwired backend never claims it can preserve records.

Source

fn commit_and_publish( &self, records: &[OpRecord], ref_updates: &[RefUpdate], scope: Option<&str>, ) -> Result<()>

The write chokepoint (heddle#330 §2.2 r18): append the caller-supplied ref-carrying record batch (phase 4, typed OpRecords) before publishing the atomic ref batch (phase 5), record-before-publish. The seam is per backend: the file backend (RefManager) earns atomicity by oplog-append-then-publish + per-read reconciliation; the Postgres backend co-commits the record row and ref/head rows in one SQL transaction (native ACID).

The default publishes without a record — backends with an injected committer override it.

Fail closed (heddle#354 r9, cid 3330304656). A backend with no record committer MUST NOT publish the ref batch while silently dropping the records it was handed — committed data must never be lost. A record-free publish has nothing to lose and stays on the plain path; a publish carrying records is refused with an error so the caller learns the records would have vanished, rather than discovering it after the fact via a reconcile that folds an empty tail.

Source

fn inspect_ref_summary_index(&self) -> Result<RefSummaryIndexInspection>

Source

fn rebuild_ref_summary_index(&self) -> Result<RefSummaryIndexInspection>

Source

fn pack_refs(&self) -> Result<()>

Source

fn cleanup_stale_temps(&self)

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§