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 index 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 index only.

Returns the kind of hash used in this instance.

source

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

Available on crate feature index only.

Return the raw byte slice representing this hash.

source

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

Available on crate feature index only.

Return the raw mutable byte slice representing this hash.

source

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

Available on crate feature index only.

The hash of an empty blob.

source

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

Available on crate feature index only.

The hash of an empty tree.

source

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

Available on crate feature index only.

Returns an instances whose bytes are all zero.

source

pub fn is_null(&self) -> bool

Available on crate feature index only.

Returns true if this hash consists of all null bytes.

source

pub fn is_empty_blob(&self) -> bool

Available on crate feature index only.

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

source

pub fn is_empty_tree(&self) -> bool

Available on crate feature index only.

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

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 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 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<&[u8]> for ObjectId

source§

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

Converts to this type from the input type.
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, E>( self, find: Find ) -> Ancestors<Find, fn(_: &oid) -> bool, State>where Find: for<'a> FnMut(&oid, &'a mut Vec<u8>) -> Result<CommitRefIter<'a>, E>, E: Error + Send + Sync + 'static,

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) -> Selfwhere Self: Sized,

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

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

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

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

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

impl PartialEq<&oid> for ObjectId

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<'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 PartialEq<ObjectId> for &oid

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

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 PartialOrd<ObjectId> 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

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

source§

impl StructuralPartialEq for ObjectId

Auto Trait Implementations§

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
§

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

§

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 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.
source§

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