Enum gix::ObjectId

source ·
pub enum ObjectId {
    Sha1([u8; 20]),
}
Expand description

An owned hash identifying objects, most commonly Sha1

Variants§

§

Sha1([u8; 20])

A SHA 1 hash digest

Implementations§

source§

impl ObjectId

Hash decoding

source

pub fn from_hex(buffer: &[u8]) -> Result<ObjectId, Error>

Available on crate feature excludes only.

Create an instance from a buffer of 40 bytes encoded with hexadecimal notation.

Such a buffer can be obtained using oid::write_hex_to(buffer)

source§

impl ObjectId

Access and conversion

source

pub fn kind(&self) -> Kind

Available on crate feature excludes only.

Returns the kind of hash used in this instance.

source

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

Available on crate feature excludes only.

Return the raw byte slice representing this hash.

source

pub fn as_mut_slice(&mut self) -> &mut [u8]

Available on crate feature excludes only.

Return the raw mutable byte slice representing this hash.

source

pub const fn empty_blob(hash: Kind) -> ObjectId

Available on crate feature excludes only.

The hash of an empty blob.

source

pub const fn empty_tree(hash: Kind) -> ObjectId

Available on crate feature excludes only.

The hash of an empty tree.

source

pub const fn null(kind: Kind) -> ObjectId

Available on crate feature excludes only.

Returns an instances whose bytes are all zero.

source

pub fn is_null(&self) -> bool

Available on crate feature excludes only.

Returns true if this hash consists of all null bytes.

source

pub fn is_empty_blob(&self) -> bool

Available on crate feature excludes only.

Returns true if this hash is equal to an empty blob.

source

pub fn is_empty_tree(&self) -> bool

Available on crate feature excludes only.

Returns true if this hash is equal to an empty tree.

source§

impl ObjectId

Lifecycle

source

pub fn from_bytes_or_panic(bytes: &[u8]) -> ObjectId

Available on crate feature excludes only.

Convert bytes into an owned object Id or panic if the slice length doesn’t indicate a supported hash.

Use Self::try_from(bytes) for a fallible version.

source§

impl ObjectId

This impl block contains no items.

Sha1 hash specific methods

Methods from Deref<Target = oid>§

source

pub fn kind(&self) -> Kind

Available on crate feature excludes only.

The kind of hash used for this instance.

source

pub fn first_byte(&self) -> u8

Available on crate feature excludes 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 excludes only.

Interpret this object id as raw byte slice.

source

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

Available on crate feature excludes 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 excludes only.

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

source

pub fn is_null(&self) -> bool

Available on crate feature excludes only.

Returns true if this hash consists of all null bytes.

source

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

Available on crate feature excludes 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 excludes only.

Write ourselves to out in hexadecimal notation.

Trait Implementations§

source§

impl AsRef<oid> for ObjectId

source§

fn as_ref(&self) -> &oid

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

impl Borrow<oid> for ObjectId

source§

fn borrow(&self) -> &oid

Immutably borrows from an owned value. Read more
source§

impl Clone for ObjectId

source§

fn clone(&self) -> ObjectId

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 Debug for ObjectId

source§

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

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

impl Deref for ObjectId

§

type Target = oid

The resulting type after dereferencing.
source§

fn deref(&self) -> &<ObjectId as Deref>::Target

Dereferences the value.
source§

impl<'de> Deserialize<'de> for ObjectId

source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<ObjectId, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for ObjectId

source§

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

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

impl From<&oid> for ObjectId

source§

fn from(v: &oid) -> ObjectId

Converts to this type from the input type.
source§

impl From<[u8; 20]> for ObjectId

source§

fn from(v: [u8; 20]) -> ObjectId

Converts to this type from the input type.
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 From<ObjectId> for Prefix

source§

fn from(oid: ObjectId) -> Prefix

Converts to this type from the input type.
source§

impl FromStr for ObjectId

§

type Err = Error

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<ObjectId, <ObjectId as FromStr>::Err>

Parses a string s to return a value of this type. Read more
source§

impl Hash for ObjectId

source§

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

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 ObjectIdExt for ObjectId

source§

fn ancestors<Find>(self, find: Find) -> Simple<Find, fn(_: &oid) -> bool>
where Find: Find,

Create an iterator over the ancestry of the commits reachable from this id, which must be a commit.
source§

fn attach(self, repo: &Repository) -> Id<'_>

Infuse this object id repo access.
source§

impl Ord for ObjectId

source§

fn cmp(&self, other: &ObjectId) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq<&oid> for ObjectId

source§

fn eq(&self, other: &&oid) -> bool

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

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

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

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

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

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

impl PartialEq<ObjectId> for &oid

source§

fn eq(&self, other: &ObjectId) -> bool

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

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

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

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

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

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

impl PartialEq for ObjectId

source§

fn eq(&self, other: &ObjectId) -> bool

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

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

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

impl PartialOrd for ObjectId

source§

fn partial_cmp(&self, other: &ObjectId) -> 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

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

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

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

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

impl Serialize for ObjectId

source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl TryFrom<&[u8]> for ObjectId

§

type Error = Error

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

fn try_from( bytes: &[u8], ) -> Result<ObjectId, <ObjectId as TryFrom<&[u8]>>::Error>

Performs the conversion.
source§

impl TryFrom<Target> for ObjectId

§

type Error = Target

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

fn try_from( value: Target, ) -> Result<ObjectId, <ObjectId as TryFrom<Target>>::Error>

Performs the conversion.
source§

impl Copy for ObjectId

source§

impl Eq for ObjectId

source§

impl StructuralPartialEq for ObjectId

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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 T
where 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.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where 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 T
where 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 T
where 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 T
where 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.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,