Struct git_repository::Object
source · [−]pub struct Object<'repo> {
pub id: ObjectId,
pub kind: Kind,
pub data: Vec<u8>,
/* private fields */
}
Expand description
A decoded object with a reference to its owning repository.
Fields
id: ObjectId
The id of the object
kind: Kind
The kind of the object
data: Vec<u8>
The fully decoded object data
Implementations
sourceimpl<'repo> Object<'repo>
impl<'repo> Object<'repo>
sourcepub fn peel_to_kind(self, kind: Kind) -> Result<Self, Error>
pub fn peel_to_kind(self, kind: Kind) -> Result<Self, Error>
Follow tags to their target and commits to trees until the given kind
of object is encountered.
Note that this object doesn’t necessarily have to be the end of the chain.
Typical values are Kind::Commit
or Kind::Tree
.
Follow all tag object targets until a commit, tree or blob is reached.
Note that this method is different from peel_to_kind(…)
as it won’t
peel commits to their tree, but handles tags only.
sourceimpl<'repo> Object<'repo>
impl<'repo> Object<'repo>
Consuming conversions to attached object kinds.
sourcepub fn into_tree(self) -> Tree<'repo>
pub fn into_tree(self) -> Tree<'repo>
Transform this object into a tree, or panic if it is none.
sourcepub fn into_commit(self) -> Commit<'repo>
pub fn into_commit(self) -> Commit<'repo>
Transform this object into a commit, or panic if it is none.
sourcepub fn try_into_commit(self) -> Result<Commit<'repo>, Error>
pub fn try_into_commit(self) -> Result<Commit<'repo>, Error>
Transform this object into a commit, or return it as part of the Err
if it is no commit.
sourcepub fn try_into_tag(self) -> Result<Tag<'repo>, Error>
pub fn try_into_tag(self) -> Result<Tag<'repo>, Error>
Transform this object into a tag, or return it as part of the Err
if it is no commit.
sourcepub fn try_into_tree(self) -> Result<Tree<'repo>, Error>
pub fn try_into_tree(self) -> Result<Tree<'repo>, Error>
Transform this object into a tree, or return it as part of the Err
if it is no tree.
sourceimpl<'repo> Object<'repo>
impl<'repo> Object<'repo>
sourcepub fn detached(&self) -> DetachedObject
pub fn detached(&self) -> DetachedObject
Create an owned instance of this object, copying our data in the process.
sourcepub fn detach(self) -> DetachedObject
pub fn detach(self) -> DetachedObject
Sever the connection to the Repository
and turn this instance into a standalone object.
sourceimpl<'repo> Object<'repo>
impl<'repo> Object<'repo>
Conversions to detached, lower-level object types.
sourcepub fn to_commit_ref(&self) -> CommitRef<'_>
pub fn to_commit_ref(&self) -> CommitRef<'_>
Obtain a fully parsed commit whose fields reference our data buffer,
Panic
- this object is not a commit
- the commit could not be decoded
sourcepub fn try_to_commit_ref(&self) -> Result<CommitRef<'_>, Error>
pub fn try_to_commit_ref(&self) -> Result<CommitRef<'_>, Error>
Obtain a fully parsed commit whose fields reference our data buffer.
sourcepub fn to_commit_ref_iter(&self) -> CommitRefIter<'_>
pub fn to_commit_ref_iter(&self) -> CommitRefIter<'_>
sourcepub fn try_to_commit_ref_iter(&self) -> Option<CommitRefIter<'_>>
pub fn try_to_commit_ref_iter(&self) -> Option<CommitRefIter<'_>>
Obtain a commit token iterator from the data in this instance, if it is a commit.
sourcepub fn to_tag_ref_iter(&self) -> TagRefIter<'_>
pub fn to_tag_ref_iter(&self) -> TagRefIter<'_>
sourcepub fn try_to_tag_ref_iter(&self) -> Option<TagRefIter<'_>>
pub fn try_to_tag_ref_iter(&self) -> Option<TagRefIter<'_>>
sourcepub fn to_tag_ref(&self) -> TagRef<'_>
pub fn to_tag_ref(&self) -> TagRef<'_>
Obtain a tag object from the data in this instance.
Panic
- this object is not a tag
- the tag could not be decoded
sourcepub fn try_to_tag_ref(&self) -> Result<TagRef<'_>, Error>
pub fn try_to_tag_ref(&self) -> Result<TagRef<'_>, Error>
Obtain a fully parsed tag object whose fields reference our data buffer.
Trait Implementations
sourceimpl<'repo> From<Object<'repo>> for DetachedObject
impl<'repo> From<Object<'repo>> for DetachedObject
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> ToHex for T where
T: AsRef<[u8]>,
impl<T> ToHex for T where
T: AsRef<[u8]>,
sourcefn encode_hex<U>(&self) -> U where
U: FromIterator<char>,
fn encode_hex<U>(&self) -> U where
U: FromIterator<char>,
Encode the hex strict representing self
into the result. Lower case
letters are used (e.g. f9b4ca
) Read more
sourcefn encode_hex_upper<U>(&self) -> U where
U: FromIterator<char>,
fn encode_hex_upper<U>(&self) -> U where
U: FromIterator<char>,
Encode the hex strict representing self
into the result. Upper case
letters are used (e.g. F9B4CA
) Read more