Struct Tree

Source
pub struct Tree {
    pub hash: Hash,
    pub entries: BTreeMap<Name, Entry>,
    /* private fields */
}
Expand description

A parsed git tree (~directory)

§Example

// The initial commit of this project's git repository
let repository  = Repository::from_regular_repository(".").unwrap();
let hcommit     = commit::Hash::from_str("02c4f0499bcf979ad86d9ef5b61ffc51b1394bef").unwrap();
let htree       = tree  ::Hash::from_str("88824f5315abd219d2f6f5f68fe69f32386ffc00").unwrap();
let hgitignore  = blob  ::Hash::from_str("96ef6c0b944e24fc22f51f18136cd62ffd5b0b8f").unwrap();

let tree = Tree::read(&repository, &htree).unwrap();
assert_eq!(tree.hash, htree);

let gitignore = tree.entries.get(".gitignore").unwrap();
assert_eq!(gitignore.permissions,   "100644".parse().unwrap());
assert_eq!(gitignore.hash,          hgitignore);
assert_eq!(gitignore.name,          ".gitignore");

Fields§

§hash: Hash

The Hash referencing this Tree

§entries: BTreeMap<Name, Entry>

A dictionary of references to Trees or Blobs and their associated Names and Permissions

Implementations§

Source§

impl Tree

Source

pub fn read(repository: &Repository, hash: &Hash) -> Result<Self>

Read a local Tree from a given Repository

Auto Trait Implementations§

§

impl Freeze for Tree

§

impl RefUnwindSafe for Tree

§

impl Send for Tree

§

impl Sync for Tree

§

impl Unpin for Tree

§

impl UnwindSafe for Tree

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Source§

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.