Skip to main content

ReftableStack

Struct ReftableStack 

Source
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

Source

pub fn open(git_dir: &Path) -> Result<Self>

Open an existing reftable stack.

Source

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.

Source

pub fn lookup_ref(&self, name: &str) -> Result<Option<RefRecord>>

Look up a single ref across all tables (most recent wins).

Source

pub fn read_logs_for_ref(&self, refname: &str) -> Result<Vec<LogRecord>>

Read merged log records for a specific ref.

Source

pub fn replace_logs_for_ref( &mut self, refname: &str, entries: &[ReflogEntry], ) -> Result<()>

Replace all log records for one ref and compact the stack.

Source

pub fn read_all_logs(&self) -> Result<Vec<LogRecord>>

Read all log records across all tables.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn table_names(&self) -> &[String]

Return the list of table filenames in this stack.

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Same for T

Source§

type Output = T

Should always be Self
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.