Struct gix::Id

source ·
pub struct Id<'r> { /* private fields */ }
Expand description

An ObjectId with access to a repository.

Implementations§

source§

impl<'repo> Id<'repo>

An object id infused with a Repository.

source

pub fn object(&self) -> Result<Object<'repo>, Error>

Find the Object associated with this object id, and consider it an error if it doesn’t exist.

Note

There can only be one ObjectRef per Easy. To increase that limit, clone the Easy.

source

pub fn header(&self) -> Result<Header, Error>

Find the header associated with this object id, or an error if it doesn’t exist.

Use this method if there is no interest in the contents of the object, which generally is much faster to obtain.

source

pub fn try_object(&self) -> Result<Option<Object<'repo>>, Error>

Try to find the Object associated with this object id, and return None if it’s not available locally.

Note

There can only be one ObjectRef per Easy. To increase that limit, clone the Easy.

source

pub fn try_header(&self) -> Result<Option<Header>, Error>

Find the header associated with this object id, or return None if it doesn’t exist.

Use this method if there is no interest in the contents of the object, which generally is much faster to obtain.

source

pub fn shorten(&self) -> Result<Prefix, Error>

Turn this object id into a shortened id with a length in hex as configured by core.abbrev.

source

pub fn shorten_or_id(&self) -> Prefix

Turn this object id into a shortened id with a length in hex as configured by core.abbrev, or default to a prefix which equals our id in the unlikely error case.

source§

impl<'repo> Id<'repo>

source

pub fn detach(self) -> ObjectId

Turn this instance into its bare ObjectId.

source§

impl<'repo> Id<'repo>

source

pub fn ancestors(&self) -> Platform<'repo>

Obtain a platform for traversing ancestors of this commit.

Methods from Deref<Target = oid>§

source

pub fn kind(&self) -> Kind

Available on crate feature index only.

The kind of hash used for this instance.

source

pub fn first_byte(&self) -> u8

Available on crate feature index only.

The first byte of the hash, commonly used to partition a set of object ids.

source

pub fn as_bytes(&self) -> &[u8]

Available on crate feature index only.

Interpret this object id as raw byte slice.

source

pub fn to_hex_with_len(&self, len: usize) -> HexDisplay<'_>

Available on crate feature index only.

Return a type which can display itself in hexadecimal form with the len amount of characters.

source

pub fn to_hex(&self) -> HexDisplay<'_>

Available on crate feature index only.

Return a type which displays this oid as hex in full.

source

pub fn hex_to_buf(&self, buf: &mut [u8]) -> usize

Available on crate feature index only.

Write ourselves to the out in hexadecimal notation, returning the amount of written bytes.

Panics if the buffer isn’t big enough to hold twice as many bytes as the current binary size.

source

pub fn write_hex_to(&self, out: &mut dyn Write) -> Result<(), Error>

Available on crate feature index only.

Write ourselves to out in hexadecimal notation.

Trait Implementations§

source§

impl<'repo> AsRef<oid> for Id<'repo>

source§

fn as_ref(&self) -> &oid

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

impl<'r> Clone for Id<'r>

source§

fn clone(&self) -> Id<'r>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'repo> Debug for Id<'repo>

source§

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

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

impl<'repo> Deref for Id<'repo>

§

type Target = oid

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<'repo> Display for Id<'repo>

source§

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

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

impl<'repo> From<Id<'repo>> for ObjectId

source§

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

Converts to this type from the input type.
source§

impl<'a> Hash for Id<'a>

source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

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

source§

fn eq(&self, other: &Id<'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> PartialEq<Id<'repo>> for ObjectId

source§

fn eq(&self, other: &Id<'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> 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> PartialEq<ObjectDetached> for Id<'repo>

source§

fn eq(&self, other: &ObjectDetached) -> 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> PartialEq<ObjectId> for Id<'repo>

source§

fn eq(&self, other: &ObjectId) -> 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> PartialEq<oid> for Id<'repo>

source§

fn eq(&self, other: &oid) -> 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<'a> PartialOrd<Id<'a>> for Id<'a>

source§

fn partial_cmp(&self, other: &Id<'a>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<'r> Copy for Id<'r>

Auto Trait Implementations§

§

impl<'r> !RefUnwindSafe for Id<'r>

§

impl<'r> !Send for Id<'r>

§

impl<'r> !Sync for Id<'r>

§

impl<'r> Unpin for Id<'r>

§

impl<'r> !UnwindSafe for Id<'r>

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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
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.