pub struct Object<'repo> { /* private fields */ }
Expand description
A structure to represent a git object
Implementations§
source§impl<'repo> Object<'repo>
impl<'repo> Object<'repo>
sourcepub fn kind(&self) -> Option<ObjectType>
pub fn kind(&self) -> Option<ObjectType>
Get the object type of an object.
If the type is unknown, then None
is returned.
sourcepub fn peel(&self, kind: ObjectType) -> Result<Object<'repo>, Error>
pub fn peel(&self, kind: ObjectType) -> Result<Object<'repo>, Error>
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).
sourcepub fn peel_to_blob(&self) -> Result<Blob<'repo>, Error>
pub fn peel_to_blob(&self) -> Result<Blob<'repo>, Error>
Recursively peel an object until a blob is found
sourcepub fn peel_to_commit(&self) -> Result<Commit<'repo>, Error>
pub fn peel_to_commit(&self) -> Result<Commit<'repo>, Error>
Recursively peel an object until a commit is found
sourcepub fn peel_to_tag(&self) -> Result<Tag<'repo>, Error>
pub fn peel_to_tag(&self) -> Result<Tag<'repo>, Error>
Recursively peel an object until a tag is found
sourcepub fn peel_to_tree(&self) -> Result<Tree<'repo>, Error>
pub fn peel_to_tree(&self) -> Result<Tree<'repo>, Error>
Recursively peel an object until a tree is found
sourcepub fn short_id(&self) -> Result<Buf, Error>
pub fn short_id(&self) -> Result<Buf, Error>
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).
sourcepub fn as_commit(&self) -> Option<&Commit<'repo>>
pub fn as_commit(&self) -> Option<&Commit<'repo>>
Attempt to view this object as a commit.
Returns None
if the object is not actually a commit.
sourcepub fn into_commit(self) -> Result<Commit<'repo>, Object<'repo>>
pub fn into_commit(self) -> Result<Commit<'repo>, Object<'repo>>
Attempt to consume this object and return a commit.
Returns Err(self)
if this object is not actually a commit.
sourcepub fn as_tag(&self) -> Option<&Tag<'repo>>
pub fn as_tag(&self) -> Option<&Tag<'repo>>
Attempt to view this object as a tag.
Returns None
if the object is not actually a tag.
sourcepub fn into_tag(self) -> Result<Tag<'repo>, Object<'repo>>
pub fn into_tag(self) -> Result<Tag<'repo>, Object<'repo>>
Attempt to consume this object and return a tag.
Returns Err(self)
if this object is not actually a tag.
sourcepub fn as_tree(&self) -> Option<&Tree<'repo>>
pub fn as_tree(&self) -> Option<&Tree<'repo>>
Attempt to view this object as a tree.
Returns None
if the object is not actually a tree.
sourcepub fn into_tree(self) -> Result<Tree<'repo>, Object<'repo>>
pub fn into_tree(self) -> Result<Tree<'repo>, Object<'repo>>
Attempt to consume this object and return a tree.
Returns Err(self)
if this object is not actually a tree.
sourcepub fn as_blob(&self) -> Option<&Blob<'repo>>
pub fn as_blob(&self) -> Option<&Blob<'repo>>
Attempt to view this object as a blob.
Returns None
if the object is not actually a blob.