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§
Source§impl<'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
.
Sourcepub fn peel_to_tree(self) -> Result<Tree<'repo>, Error>
pub fn peel_to_tree(self) -> Result<Tree<'repo>, Error>
Peel this object into a tree and return it, if this is possible.
This will follow tag objects and commits until their tree is reached.
Sourcepub fn peel_to_commit(self) -> Result<Commit<'repo>, Error>
pub fn peel_to_commit(self) -> Result<Commit<'repo>, Error>
Peel this object into a commit and return it, if this is possible.
This will follow tag objects until a commit is reached.
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.
Source§impl<'repo> Object<'repo>
impl<'repo> Object<'repo>
Consuming conversions to attached object kinds.
Sourcepub fn into_blob(self) -> Blob<'repo>
pub fn into_blob(self) -> Blob<'repo>
Transform this object into a blob, or panic if it is none.
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.
Sourcepub fn try_into_blob(self) -> Result<Blob<'repo>, Error>
pub fn try_into_blob(self) -> Result<Blob<'repo>, Error>
Transform this object into a blob, or return it as part of the Err
if it is no blob.
Source§impl Object<'_>
impl Object<'_>
Sourcepub fn detached(&self) -> ObjectDetached
pub fn detached(&self) -> ObjectDetached
Create an owned instance of this object, copying our data in the process.
Sourcepub fn detach(self) -> ObjectDetached
pub fn detach(self) -> ObjectDetached
Sever the connection to the Repository
and turn this instance into a standalone object.
Source§impl<'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.