git2

Enum AttrValue

Source
pub enum AttrValue<'string> {
    True,
    False,
    String(&'string str),
    Bytes(&'string [u8]),
    Unspecified,
}
Expand description

All possible states of an attribute.

This enum is used to interpret the value returned by Repository::get_attr and Repository::get_attr_bytes.

Variants§

§

True

The attribute is set to true.

§

False

The attribute is unset (set to false).

§

String(&'string str)

The attribute is set to a valid UTF-8 string.

§

Bytes(&'string [u8])

The attribute is set to a string that might not be valid UTF-8.

§

Unspecified

The attribute is not specified.

Implementations§

Source§

impl<'string> AttrValue<'string>

Source

pub fn from_string(value: Option<&'string str>) -> Self

Returns the state of an attribute by inspecting its value by a string.

This function always returns AttrValue::String and never returns AttrValue::Bytes when the attribute is set to a string.

Source

pub fn from_bytes(value: Option<&'string [u8]>) -> Self

Returns the state of an attribute by inspecting its value by a byte slice.

This function will perform UTF-8 validation when the attribute is set to a string, returns AttrValue::String if it’s valid UTF-8 and AttrValue::Bytes otherwise.

Source

pub fn always_bytes(value: Option<&'string [u8]>) -> Self

Returns the state of an attribute just like AttrValue::from_bytes, but skips UTF-8 validation and always returns AttrValue::Bytes when it’s set to a string.

Trait Implementations§

Source§

impl<'string> Clone for AttrValue<'string>

Source§

fn clone(&self) -> AttrValue<'string>

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<'string> Debug for AttrValue<'string>

Source§

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

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

impl PartialEq for AttrValue<'_>

Compare two AttrValues.

Note that this implementation does not differentiate between AttrValue::String and AttrValue::Bytes.

Source§

fn eq(&self, other: &AttrValue<'_>) -> 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<'string> Copy for AttrValue<'string>

Source§

impl<'string> Eq for AttrValue<'string>

Auto Trait Implementations§

§

impl<'string> Freeze for AttrValue<'string>

§

impl<'string> RefUnwindSafe for AttrValue<'string>

§

impl<'string> Send for AttrValue<'string>

§

impl<'string> Sync for AttrValue<'string>

§

impl<'string> Unpin for AttrValue<'string>

§

impl<'string> UnwindSafe for AttrValue<'string>

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 u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

Source§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T