Struct gix::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§

source§

impl<'repo> Object<'repo>

source

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.

source

pub fn peel_to_tree(self) -> Result<Tree<'repo>, Error>

Peel this object into a tree and return it, if this is possible.

source

pub fn peel_tags_to_end(self) -> Result<Self, Error>

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>

Consuming conversions to attached object kinds.

source

pub fn into_tree(self) -> Tree<'repo>

Transform this object into a tree, or panic if it is none.

source

pub fn into_commit(self) -> Commit<'repo>

Transform this object into a commit, or panic if it is none.

source

pub fn into_tag(self) -> Tag<'repo>

Transform this object into a tag, or panic if it is none.

source

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.

source

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.

source

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.

source§

impl<'repo> Object<'repo>

source

pub fn detached(&self) -> ObjectDetached

Create an owned instance of this object, copying our data in the process.

source

pub fn detach(self) -> ObjectDetached

Sever the connection to the Repository and turn this instance into a standalone object.

source§

impl<'repo> Object<'repo>

Conversions to detached, lower-level object types.

source

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
source

pub fn try_to_commit_ref(&self) -> Result<CommitRef<'_>, Error>

Obtain a fully parsed commit whose fields reference our data buffer.

source

pub fn to_commit_ref_iter(&self) -> CommitRefIter<'_>

Obtain an iterator over commit tokens like in to_commit_iter().

Panic
  • this object is not a commit
source

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.

source

pub fn to_tag_ref_iter(&self) -> TagRefIter<'_>

Obtain a tag token iterator from the data in this instance.

Panic
  • this object is not a tag
source

pub fn try_to_tag_ref_iter(&self) -> Option<TagRefIter<'_>>

Obtain a tag token iterator from the data in this instance.

Panic
  • this object is not a tag
source

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
source

pub fn try_to_tag_ref(&self) -> Result<TagRef<'_>, Error>

Obtain a fully parsed tag object whose fields reference our data buffer.

source

pub fn id(&self) -> Id<'repo>

Return the attached id of this object.

Trait Implementations§

source§

impl<'repo> AsRef<[u8]> for Object<'repo>

source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<'r> Debug for Object<'r>

source§

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

Formats the value using the given formatter. Read more
source§

impl<'a> Drop for Object<'a>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<'repo> From<Commit<'repo>> for Object<'repo>

source§

fn from(v: Commit<'repo>) -> Self

Converts to this type from the input type.
source§

impl<'repo> From<Object<'repo>> for ObjectDetached

source§

fn from(v: Object<'repo>) -> Self

Converts to this type from the input type.
source§

impl<'repo> PartialEq<Object<'repo>> for Id<'repo>

source§

fn eq(&self, other: &Object<'repo>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'repo> TryFrom<Object<'repo>> for Commit<'repo>

§

type Error = Object<'repo>

The type returned in the event of a conversion error.
source§

fn try_from(value: Object<'repo>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'repo> TryFrom<Object<'repo>> for Tag<'repo>

§

type Error = Object<'repo>

The type returned in the event of a conversion error.
source§

fn try_from(value: Object<'repo>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'repo> TryFrom<Object<'repo>> for Tree<'repo>

§

type Error = Object<'repo>

The type returned in the event of a conversion error.
source§

fn try_from(value: Object<'repo>) -> Result<Self, Self::Error>

Performs the conversion.

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§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

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

§

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.