pub struct Tree<'repo> {
    pub id: ObjectId,
    pub data: Vec<u8>,
    /* private fields */
}
Expand description

A decoded tree object with access to its owning repository.

Fields

id: ObjectId

The id of the tree

data: Vec<u8>

The fully decoded tree data

Implementations

Diffing

Return a platform to see the changes needed to create other trees, for instance.

Performance

It’s highly recommended to set an object cache to avoid extracting the same object multiple times.

Traversal

Obtain a platform for initiating a variety of traversals.

Return an iterator over tree entries.

Initialization

Obtain a tree instance by handing in all components that it is made up of.

Access

Return this tree’s identifier.

source

pub fn lookup_entry<I, P>(self, path: I) -> Result<Option<Entry>, Error>where
    I: IntoIterator<Item = P>,
    P: PartialEq<BStr>,

Follow a sequence of path components starting from this instance, and look them up one by one until the last component is looked up and its tree entry is returned.

Performance Notes

Searching tree entries is currently done in sequence, which allows to the search to be allocation free. It would be possible to re-use a vector and use a binary search instead, which might be able to improve performance over all. However, a benchmark should be created first to have some data and see which trade-off to choose here.

Why is this consunming?

The borrow checker shows pathological behaviour in loops that mutate a buffer, but also want to return from it. Workarounds include keeping an index and doing a separate access to the memory, which seems hard to do here without re-parsing the entries.

source

pub fn lookup_entry_by_path(
    self,
    relative_path: impl AsRef<Path>
) -> Result<Option<Entry>, Error>

Like lookup_entry(), but takes a Path directly via relative_path, a path relative to this tree.

Note

If any path component contains illformed UTF-8 and thus can’t be converted to bytes on platforms which can’t do so natively, the returned component will be empty which makes the lookup fail.

Trait Implementations

Formats the value using the given formatter. Read more
Executes the destructor for this type. Read more
The type returned in the event of a conversion error.
Performs the conversion.

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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

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