Struct git_pack::tree::Tree[][src]

pub struct Tree<T> { /* fields omitted */ }
Expand description

A tree that allows one-time iteration over all nodes and their children, consuming it in the process, while being shareable among threads without a lock. It does this by making the guarantee that iteration only happens once.

Implementations

Iteration

Return an iterator over chunks of roots. Roots are not children themselves, they have no parents.

Traverse this tree of delta objects with a function inspect_object to process each object at will.

  • should_run_in_parallel() -> bool returns true if the underlying pack is big enough to warrant parallel traversal at all.
  • resolve(EntrySlice, &mut Vec<u8>) -> Option<()> resolves the bytes in the pack for the given EntrySlice and stores them in the output vector. It returns Some(()) if the object existed in the pack, or None to indicate a resolution error, which would abort the operation as well.
  • object_progress is a progress instance to track progress for each object in the traversal.
  • size_progress is a progress instance to track the overall progress.
  • tread_limit is limits the amount of threads used if Some or otherwise defaults to all available logical cores.
  • pack_entries_end marks one-past-the-last byte of the last entry in the pack, as the last entries size would otherwise be unknown as it’s not part of the index file.
  • new_thread_state() -> State is a function to create state to be used in each thread, invoked once per thread.
  • inspect_object(node_data: &mut T, progress: Progress, context: Context<ThreadLocal State>) -> Result<(), CustomError> is a function running for each thread receiving fully decoded objects along with contextual information, which either succceeds with Ok(()) or returns a CustomError. Note that node_data can be modified to allow storing maintaining computation results on a per-object basis.

This method returns a vector of all tree items, along with their potentially modified custom node data.

Note that this method consumed the Tree to assure safe parallel traversal with mutation support.

Generate tree from certain input

Create a new Tree from any data sorted by offset, ascending as returned by the data_sorted_by_offsets iterator.

  • get_pack_offset(item: &T) -> PackOffset` is a function returning the pack offset of the given item, which can be used for obtaining the objects entry within the pack.
  • pack_path is the path to the pack file itself and from which to read the entry data, which is a pack file matching the offsets returned by get_pack_offset(…).
  • progress is used to track progress when creating the tree.
  • resolve_in_pack_id(git_hash::oid) -> Option<PackOffset> takes an object ID and tries to resolve it to an object within this pack if possible. Failing to do so aborts the operation, and this function is not expected to be called in usual packs. It’s a theoretical possibility though.

Note that the sort order is ascending. The given pack file path must match the provided offsets.

Instantiate a empty tree capable of storing num_objects amounts of items.

Add a new root node, one that only has children but is not a child itself, at the given pack offset and associate custom data with it.

Add a child of the item at base_offset which itself resides at pack offset and associate custom data with it.

Transform this Tree into its items.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Converts self into T using Into<T>. Read more

Converts self into a target type. Read more

Causes self to use its Binary implementation when Debug-formatted.

Causes self to use its Display implementation when Debug-formatted. Read more

Causes self to use its LowerExp implementation when Debug-formatted. Read more

Causes self to use its LowerHex implementation when Debug-formatted. Read more

Causes self to use its Octal implementation when Debug-formatted.

Causes self to use its Pointer implementation when Debug-formatted. Read more

Causes self to use its UpperExp implementation when Debug-formatted. Read more

Causes self to use its UpperHex implementation when Debug-formatted. Read more

Performs the conversion.

Performs the conversion.

Pipes by value. This is generally the method you want to use. Read more

Borrows self and passes that borrow into the pipe function. Read more

Mutably borrows self and passes that borrow into the pipe function. Read more

Borrows self, then passes self.borrow() into the pipe function. Read more

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more

Borrows self, then passes self.as_ref() into the pipe function.

Mutably borrows self, then passes self.as_mut() into the pipe function. Read more

Borrows self, then passes self.deref() into the pipe function.

Mutably borrows self, then passes self.deref_mut() into the pipe function. Read more

Pipes a value into a function that cannot ordinarily be called in suffix position. Read more

Pipes a trait borrow into a function that cannot normally be called in suffix position. Read more

Pipes a trait mutable borrow into a function that cannot normally be called in suffix position. Read more

Pipes a trait borrow into a function that cannot normally be called in suffix position. Read more

Pipes a trait mutable borrow into a function that cannot normally be called in suffix position. Read more

Pipes a dereference into a function that cannot normally be called in suffix position. Read more

Pipes a mutable dereference into a function that cannot normally be called in suffix position. Read more

Pipes a reference into a function that cannot ordinarily be called in suffix position. Read more

Pipes a mutable reference into a function that cannot ordinarily be called in suffix position. Read more

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

Immutable access to a value. Read more

Mutable access to a value. Read more

Immutable access to the Borrow<B> of a value. Read more

Mutable access to the BorrowMut<B> of a value. Read more

Immutable access to the AsRef<R> view of a value. Read more

Mutable access to the AsMut<R> view of a value. Read more

Immutable access to the Deref::Target of a value. Read more

Mutable access to the Deref::Target of a value. Read more

Calls .tap() only in debug builds, and is erased in release builds.

Calls .tap_mut() only in debug builds, and is erased in release builds. Read more

Calls .tap_borrow() only in debug builds, and is erased in release builds. Read more

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds. Read more

Calls .tap_ref() only in debug builds, and is erased in release builds. Read more

Calls .tap_ref_mut() only in debug builds, and is erased in release builds. Read more

Calls .tap_deref() only in debug builds, and is erased in release builds. Read more

Calls .tap_deref_mut() only in debug builds, and is erased in release builds. Read more

Provides immutable access for inspection. Read more

Calls tap in debug builds, and does nothing in release builds.

Provides mutable access for modification. Read more

Calls tap_mut in debug builds, and does nothing in release builds.

Provides immutable access to the reference for inspection.

Calls tap_ref in debug builds, and does nothing in release builds.

Provides mutable access to the reference for modification.

Calls tap_ref_mut in debug builds, and does nothing in release builds.

Provides immutable access to the borrow for inspection. Read more

Calls tap_borrow in debug builds, and does nothing in release builds.

Provides mutable access to the borrow for modification.

Calls tap_borrow_mut in debug builds, and does nothing in release builds. Read more

Immutably dereferences self for inspection.

Calls tap_deref in debug builds, and does nothing in release builds.

Mutably dereferences self for modification.

Calls tap_deref_mut in debug builds, and does nothing in release builds. Read more

Attempts to convert self into T using TryInto<T>. Read more

Attempts to convert self into a target type. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.