use std::borrow::BorrowMut;
use gix_object::TreeRefIter;
use gix_traverse::tree::breadthfirst;
pub trait Sealed {}
pub trait TreeIterExt: Sealed {
fn traverse<StateMut, Find, V>(
&self,
state: StateMut,
objects: Find,
delegate: &mut V,
) -> Result<(), breadthfirst::Error>
where
Find: gix_object::Find,
StateMut: BorrowMut<breadthfirst::State>,
V: gix_traverse::tree::Visit;
}
impl Sealed for TreeRefIter<'_> {}
impl TreeIterExt for TreeRefIter<'_> {
fn traverse<StateMut, Find, V>(
&self,
state: StateMut,
objects: Find,
delegate: &mut V,
) -> Result<(), breadthfirst::Error>
where
Find: gix_object::Find,
StateMut: BorrowMut<breadthfirst::State>,
V: gix_traverse::tree::Visit,
{
breadthfirst(*self, state, objects, delegate)
}
}
pub trait TreeEntryRefExt<'a>: 'a {
fn attach<'repo>(self, repo: &'repo crate::Repository) -> crate::object::tree::EntryRef<'repo, 'a>;
}
impl<'a> TreeEntryRefExt<'a> for gix_object::tree::EntryRef<'a> {
fn attach<'repo>(self, repo: &'repo crate::Repository) -> crate::object::tree::EntryRef<'repo, 'a> {
crate::object::tree::EntryRef { inner: self, repo }
}
}
pub trait TreeEntryExt {
fn attach(self, repo: &crate::Repository) -> crate::object::tree::Entry<'_>;
}
impl TreeEntryExt for gix_object::tree::Entry {
fn attach(self, repo: &crate::Repository) -> crate::object::tree::Entry<'_> {
crate::object::tree::Entry { inner: self, repo }
}
}
#[cfg(feature = "blob-diff")]
pub trait TreeDiffChangeExt {
fn attach<'old, 'new>(
&self,
old_repo: &'old crate::Repository,
new_repo: &'new crate::Repository,
) -> crate::object::tree::diff::Change<'_, 'old, 'new>;
}