Struct git2::Object[][src]

pub struct Object<'repo> { /* fields omitted */ }
Expand description

A structure to represent a git object

Implementations

impl<'repo> Object<'repo>[src]

pub fn id(&self) -> Oid[src]

Get the id (SHA1) of a repository object

pub fn kind(&self) -> Option<ObjectType>[src]

Get the object type of an object.

If the type is unknown, then None is returned.

pub fn peel(&self, kind: ObjectType) -> Result<Object<'repo>, Error>[src]

Recursively peel an object until an object of the specified type is met.

If you pass Any as the target type, then the object will be peeled until the type changes (e.g. a tag will be chased until the referenced object is no longer a tag).

pub fn peel_to_blob(&self) -> Result<Blob<'repo>, Error>[src]

Recursively peel an object until a blob is found

pub fn peel_to_commit(&self) -> Result<Commit<'repo>, Error>[src]

Recursively peel an object until a commit is found

pub fn peel_to_tag(&self) -> Result<Tag<'repo>, Error>[src]

Recursively peel an object until a tag is found

pub fn peel_to_tree(&self) -> Result<Tree<'repo>, Error>[src]

Recursively peel an object until a tree is found

pub fn short_id(&self) -> Result<Buf, Error>[src]

Get a short abbreviated OID string for the object

This starts at the “core.abbrev” length (default 7 characters) and iteratively extends to a longer string if that length is ambiguous. The result will be unambiguous (at least until new objects are added to the repository).

pub fn as_commit(&self) -> Option<&Commit<'repo>>[src]

Attempt to view this object as a commit.

Returns None if the object is not actually a commit.

pub fn into_commit(self) -> Result<Commit<'repo>, Object<'repo>>[src]

Attempt to consume this object and return a commit.

Returns Err(self) if this object is not actually a commit.

pub fn as_tag(&self) -> Option<&Tag<'repo>>[src]

Attempt to view this object as a tag.

Returns None if the object is not actually a tag.

pub fn into_tag(self) -> Result<Tag<'repo>, Object<'repo>>[src]

Attempt to consume this object and return a tag.

Returns Err(self) if this object is not actually a tag.

pub fn as_tree(&self) -> Option<&Tree<'repo>>[src]

Attempt to view this object as a tree.

Returns None if the object is not actually a tree.

pub fn into_tree(self) -> Result<Tree<'repo>, Object<'repo>>[src]

Attempt to consume this object and return a tree.

Returns Err(self) if this object is not actually a tree.

pub fn as_blob(&self) -> Option<&Blob<'repo>>[src]

Attempt to view this object as a blob.

Returns None if the object is not actually a blob.

pub fn into_blob(self) -> Result<Blob<'repo>, Object<'repo>>[src]

Attempt to consume this object and return a blob.

Returns Err(self) if this object is not actually a blob.

pub fn describe(&self, opts: &DescribeOptions) -> Result<Describe<'_>, Error>[src]

Describes a commit

Performs a describe operation on this commitish object.

Trait Implementations

impl<'repo> Clone for Object<'repo>[src]

fn clone(&self) -> Object<'repo>[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<'repo> Debug for Object<'repo>[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>[src]

Formats the value using the given formatter. Read more

impl<'repo> Drop for Object<'repo>[src]

fn drop(&mut self)[src]

Executes the destructor for this type. Read more

Auto Trait Implementations

impl<'repo> RefUnwindSafe for Object<'repo>

impl<'repo> !Send for Object<'repo>

impl<'repo> !Sync for Object<'repo>

impl<'repo> Unpin for Object<'repo>

impl<'repo> UnwindSafe for Object<'repo>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.