Struct gix_revision::Graph

source ·
pub struct Graph<'find, T> { /* private fields */ }
Expand description

A graph of commits which additionally allows to associate data with commits.

It starts empty, but each access may fill it with commit information. Note that the traversal can be accelerated if a commit-graph is also made available.

Implementations§

source§

impl<'find, T> Graph<'find, T>

source

pub fn new<Find, E>(find: Find, cache: impl Into<Option<Graph>>) -> Selfwhere Find: for<'a> FnMut(&oid, &'a mut Vec<u8>) -> Result<Option<CommitRefIter<'a>>, E> + 'find, E: Error + Send + Sync + 'static,

Create a new instance with find to retrieve commits and optionally cache to accelerate commit access.

source

pub fn contains(&self, id: &oid) -> bool

Returns true if id has data associated with it, meaning that we processed it already.

source

pub fn get(&self, id: &oid) -> Option<&T>

Returns the data associated with id if available.

source

pub fn get_mut(&mut self, id: &oid) -> Option<&mut T>

Returns the data associated with id if available as mutable reference.

source

pub fn insert(&mut self, id: ObjectId, value: T) -> Option<T>

Insert id into the graph and associate it with value, returning the previous value associated with it if it existed.

source

pub fn clear(&mut self)

Remove all data from the graph to start over.

source

pub fn try_lookup(&mut self, id: &oid) -> Result<Option<Commit<'_>>, Error>

Try to lookup id and return a handle to it for accessing its data, but don’t fail if the commit doesn’t exist.

It’s possible that commits don’t exist if the repository is shallow.

source

pub fn lookup(&mut self, id: &oid) -> Result<Commit<'_>, Error>

Lookup id and return a handle to it, or fail if it doesn’t exist.

source

pub fn insert_parents( &mut self, id: &oid, new_parent_data: impl FnMut(ObjectId, u64) -> T, update_existing: impl FnMut(ObjectId, &mut T), first_parent: bool ) -> Result<(), Error>

Insert the parents of commit named id to the graph and associate new parents with data by calling new_parent_data(parent_id, committer_timestamp), or update existing parents data with update_existing(parent_id, &mut existing_data). If first_parent is true, only the first parent of commits will be looked at.

Trait Implementations§

source§

impl<'a, 'find, T> Index<&'a oid> for Graph<'find, T>

§

type Output = T

The returned type after indexing.
source§

fn index(&self, index: &'a oid) -> &Self::Output

Performs the indexing (container[index]) operation. Read more

Auto Trait Implementations§

§

impl<'find, T> !RefUnwindSafe for Graph<'find, T>

§

impl<'find, T> !Send for Graph<'find, T>

§

impl<'find, T> !Sync for Graph<'find, T>

§

impl<'find, T> Unpin for Graph<'find, T>where T: Unpin,

§

impl<'find, T> !UnwindSafe for Graph<'find, T>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.