mirror of
https://github.com/martinvonz/jj.git
synced 2025-02-05 19:14:43 +00:00
index: add wrapper functions to DefaultReadonlyIndex to remove pub(super) field
This commit is contained in:
parent
c0a12a7cbc
commit
2abbb637e3
3 changed files with 12 additions and 4 deletions
|
@ -487,6 +487,6 @@ impl MutableIndex for DefaultMutableIndex {
|
|||
.as_any()
|
||||
.downcast_ref::<DefaultReadonlyIndex>()
|
||||
.expect("index to merge in must be a DefaultReadonlyIndex");
|
||||
self.0.merge_in(other.0.clone());
|
||||
self.0.merge_in(other.as_segment().clone());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -380,9 +380,17 @@ impl IndexSegment for ReadonlyIndexSegment {
|
|||
|
||||
/// Commit index backend which stores data on local disk.
|
||||
#[derive(Debug)]
|
||||
pub struct DefaultReadonlyIndex(pub(super) Arc<ReadonlyIndexSegment>);
|
||||
pub struct DefaultReadonlyIndex(Arc<ReadonlyIndexSegment>);
|
||||
|
||||
impl DefaultReadonlyIndex {
|
||||
pub(super) fn from_segment(segment: Arc<ReadonlyIndexSegment>) -> Self {
|
||||
DefaultReadonlyIndex(segment)
|
||||
}
|
||||
|
||||
pub(super) fn as_segment(&self) -> &Arc<ReadonlyIndexSegment> {
|
||||
&self.0
|
||||
}
|
||||
|
||||
pub fn as_composite(&self) -> CompositeIndex {
|
||||
self.0.as_composite()
|
||||
}
|
||||
|
|
|
@ -236,7 +236,7 @@ impl IndexStore for DefaultIndexStore {
|
|||
} else {
|
||||
self.index_at_operation(store, op).unwrap()
|
||||
};
|
||||
Box::new(DefaultReadonlyIndex(index_segment))
|
||||
Box::new(DefaultReadonlyIndex::from_segment(index_segment))
|
||||
}
|
||||
|
||||
fn write_index(
|
||||
|
@ -257,6 +257,6 @@ impl IndexStore for DefaultIndexStore {
|
|||
"Failed to associate commit index file with a operation {op_id:?}: {err}"
|
||||
))
|
||||
})?;
|
||||
Ok(Box::new(DefaultReadonlyIndex(index_segment)))
|
||||
Ok(Box::new(DefaultReadonlyIndex::from_segment(index_segment)))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue