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

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.

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.

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Compare two AttrValues.

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

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

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

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.