Enum git_hash::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>

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

Returns the kind of hash used in this Id

source

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

Return the raw byte slice representing this hash

source

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

Return the raw mutable byte slice representing this hash

source

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

The hash of an empty tree

source

pub fn is_null(&self) -> bool

Returns true if this hash consists of all null bytes

source

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

Returns an Digest representing a hash with whose memory is zeroed.

Methods from Deref<Target = oid>§

source

pub fn kind(&self) -> Kind

The kind of hash used for this Digest

source

pub fn first_byte(&self) -> u8

The first byte of the hash, commonly used to partition a set of Ids

source

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

Interpret this object id as raw byte slice.

source

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

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

source

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

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

source

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

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: impl Write) -> Result<()>

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

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) -> &Self::Target

Dereferences the value.
source§

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

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::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

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

impl From<&[u8]> for ObjectId

source§

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

Converts to this type from the input type.
source§

impl From<&oid> for ObjectId

source§

fn from(v: &oid) -> Self

Converts to this type from the input type.
source§

impl From<[u8; 20]> for ObjectId

source§

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

Converts to this type from the input type.
source§

impl From<ObjectId> for Prefix

source§

fn from(oid: ObjectId) -> Self

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<Self, Self::Err>

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

impl Hash for ObjectId

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 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 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 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::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
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,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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> 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.
const: unstable · 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.
const: unstable · 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>,