pub struct ReftableStack { /* private fields */ }Expand description
Manages the $GIT_DIR/reftable/ directory and tables.list stack.
The stack provides a merged view of all tables, with later tables taking precedence over earlier ones.
Implementations§
Source§impl ReftableStack
impl ReftableStack
Sourcepub fn read_refs(&self) -> Result<Vec<RefRecord>>
pub fn read_refs(&self) -> Result<Vec<RefRecord>>
Read a merged view of all ref records.
Later tables override earlier ones. Deletion records cause the ref to be omitted from the result.
Sourcepub fn lookup_ref(&self, name: &str) -> Result<Option<RefRecord>>
pub fn lookup_ref(&self, name: &str) -> Result<Option<RefRecord>>
Look up a single ref across all tables (most recent wins).
Sourcepub fn read_logs_for_ref(&self, refname: &str) -> Result<Vec<LogRecord>>
pub fn read_logs_for_ref(&self, refname: &str) -> Result<Vec<LogRecord>>
Read merged log records for a specific ref.
Sourcepub fn replace_logs_for_ref(
&mut self,
refname: &str,
entries: &[ReflogEntry],
) -> Result<()>
pub fn replace_logs_for_ref( &mut self, refname: &str, entries: &[ReflogEntry], ) -> Result<()>
Replace all log records for one ref and compact the stack.
Sourcepub fn read_all_logs(&self) -> Result<Vec<LogRecord>>
pub fn read_all_logs(&self) -> Result<Vec<LogRecord>>
Read all log records across all tables.
Sourcepub fn max_update_index(&self) -> Result<u64>
pub fn max_update_index(&self) -> Result<u64>
Get the current max update index across all tables.
Reads the authoritative on-disk tables.list rather than the (possibly
stale) in-memory snapshot, and tolerates tables that a concurrent
compaction removed between listing and reading: such a table’s update
index is subsumed by the compacted result that replaced it, which is also
in the freshly-read list.
Sourcepub fn add_table(&mut self, data: &[u8], update_index: u64) -> Result<String>
pub fn add_table(&mut self, data: &[u8], update_index: u64) -> Result<String>
Add a new reftable to the stack.
Writes the table bytes to a new file, then atomically updates
tables.list.
Sourcepub fn write_ref(
&mut self,
refname: &str,
value: RefValue,
log: Option<LogRecord>,
opts: &WriteOptions,
) -> Result<()>
pub fn write_ref( &mut self, refname: &str, value: RefValue, log: Option<LogRecord>, opts: &WriteOptions, ) -> Result<()>
Write a ref update (add/update/delete) as a new reftable.
This is the main entry point for updating refs in a reftable repo.
Sourcepub fn write_transaction(
&mut self,
updates: Vec<ReftableTransactionUpdate>,
opts: &WriteOptions,
) -> Result<()>
pub fn write_transaction( &mut self, updates: Vec<ReftableTransactionUpdate>, opts: &WriteOptions, ) -> Result<()>
Write several ref updates as a single reftable transaction.
All ref and log records are stored in one table with one shared update
index. This mirrors Git’s reftable transaction behavior and keeps
compacted table layout stable for large update-ref --stdin batches.
Sourcepub fn compact(&mut self) -> Result<()>
pub fn compact(&mut self) -> Result<()>
Compact all tables into a single table.
git pack-refs always rewrites the whole stack into a single,
canonically-laid-out table even when there is just one table, so that
padding/block layout match the configured write options.
Sourcepub fn table_names(&self) -> &[String]
pub fn table_names(&self) -> &[String]
Return the list of table filenames in this stack.