Struct gix_config::color::Attribute
source · pub struct Attribute(_);
Expand description
Discriminating enum for Color
attributes.
gix-config
supports modifiers and their negators. The negating color
attributes are equivalent to having a no
or no-
prefix to the normal
variant.
Implementations§
source§impl Attribute
impl Attribute
pub const BOLD: Attribute = Self::from_bits_retain(1 << 1)
pub const DIM: Attribute = Self::from_bits_retain(1 << 2)
pub const ITALIC: Attribute = Self::from_bits_retain(1 << 3)
pub const UL: Attribute = Self::from_bits_retain(1 << 4)
pub const BLINK: Attribute = Self::from_bits_retain(1 << 5)
pub const REVERSE: Attribute = Self::from_bits_retain(1 << 6)
pub const STRIKE: Attribute = Self::from_bits_retain(1 << 7)
sourcepub const RESET: Attribute = Self::from_bits_retain(1 << 8)
pub const RESET: Attribute = Self::from_bits_retain(1 << 8)
Reset is special as we have to be able to parse it, without git actually doing anything with it
pub const NO_DIM: Attribute = Self::from_bits_retain(1 << 21)
pub const NO_BOLD: Attribute = Self::from_bits_retain(1 << 22)
pub const NO_ITALIC: Attribute = Self::from_bits_retain(1 << 23)
pub const NO_UL: Attribute = Self::from_bits_retain(1 << 24)
pub const NO_BLINK: Attribute = Self::from_bits_retain(1 << 25)
pub const NO_REVERSE: Attribute = Self::from_bits_retain(1 << 26)
pub const NO_STRIKE: Attribute = Self::from_bits_retain(1 << 27)
source§impl Attribute
impl Attribute
sourcepub const fn from_bits(bits: u32) -> Option<Attribute>
pub const fn from_bits(bits: u32) -> Option<Attribute>
Convert from underlying bit representation, unless that representation contains bits that do not correspond to a flag.
sourcepub const fn from_bits_truncate(bits: u32) -> Attribute
pub const fn from_bits_truncate(bits: u32) -> Attribute
Convert from underlying bit representation, dropping any bits that do not correspond to flags.
sourcepub const fn from_bits_retain(bits: u32) -> Attribute
pub const fn from_bits_retain(bits: u32) -> Attribute
Convert from underlying bit representation, preserving all bits (even those not corresponding to a defined flag).
sourcepub fn from_name(name: &str) -> Option<Attribute>
pub fn from_name(name: &str) -> Option<Attribute>
Get the value for a flag from its stringified name.
Names are case-sensitive, so must correspond exactly to the identifier given to the flag.
sourcepub const fn intersects(&self, other: Attribute) -> bool
pub const fn intersects(&self, other: Attribute) -> bool
Returns true
if there are flags common to both self
and other
.
sourcepub const fn contains(&self, other: Attribute) -> bool
pub const fn contains(&self, other: Attribute) -> bool
Returns true
if all of the flags in other
are contained within self
.
sourcepub fn set(&mut self, other: Attribute, value: bool)
pub fn set(&mut self, other: Attribute, value: bool)
Inserts or removes the specified flags depending on the passed value.
sourcepub const fn intersection(self, other: Attribute) -> Attribute
pub const fn intersection(self, other: Attribute) -> Attribute
Returns the intersection between the flags in self
and
other
.
Specifically, the returned set contains only the flags which are
present in both self
and other
.
This is equivalent to using the &
operator (e.g.
ops::BitAnd
), as in flags & other
.
sourcepub const fn union(self, other: Attribute) -> Attribute
pub const fn union(self, other: Attribute) -> Attribute
Returns the union of between the flags in self
and other
.
Specifically, the returned set contains all flags which are
present in either self
or other
, including any which are
present in both (see Self::symmetric_difference
if that
is undesirable).
This is equivalent to using the |
operator (e.g.
ops::BitOr
), as in flags | other
.
sourcepub const fn difference(self, other: Attribute) -> Attribute
pub const fn difference(self, other: Attribute) -> Attribute
Returns the difference between the flags in self
and other
.
Specifically, the returned set contains all flags present in
self
, except for the ones present in other
.
It is also conceptually equivalent to the “bit-clear” operation:
flags & !other
(and this syntax is also supported).
This is equivalent to using the -
operator (e.g.
ops::Sub
), as in flags - other
.
sourcepub const fn symmetric_difference(self, other: Attribute) -> Attribute
pub const fn symmetric_difference(self, other: Attribute) -> Attribute
Returns the symmetric difference between the flags
in self
and other
.
Specifically, the returned set contains the flags present which
are present in self
or other
, but that are not present in
both. Equivalently, it contains the flags present in exactly
one of the sets self
and other
.
This is equivalent to using the ^
operator (e.g.
ops::BitXor
), as in flags ^ other
.
sourcepub const fn complement(self) -> Attribute
pub const fn complement(self) -> Attribute
Returns the complement of this set of flags.
Specifically, the returned set contains all the flags which are
not set in self
, but which are allowed for this type.
Alternatively, it can be thought of as the set difference
between Self::all()
and self
(e.g. Self::all() - self
)
This is equivalent to using the !
operator (e.g.
ops::Not
), as in !flags
.
Trait Implementations§
source§impl BitAndAssign<Attribute> for Attribute
impl BitAndAssign<Attribute> for Attribute
source§fn bitand_assign(&mut self, other: Attribute)
fn bitand_assign(&mut self, other: Attribute)
Disables all flags disabled in the set.
source§impl BitOrAssign<Attribute> for Attribute
impl BitOrAssign<Attribute> for Attribute
source§fn bitor_assign(&mut self, other: Attribute)
fn bitor_assign(&mut self, other: Attribute)
Adds the set of flags.
source§impl BitXorAssign<Attribute> for Attribute
impl BitXorAssign<Attribute> for Attribute
source§fn bitxor_assign(&mut self, other: Attribute)
fn bitxor_assign(&mut self, other: Attribute)
Toggles the set of flags.
source§impl Extend<Attribute> for Attribute
impl Extend<Attribute> for Attribute
source§fn extend<T>(&mut self, iterator: T)where
T: IntoIterator<Item = Attribute>,
fn extend<T>(&mut self, iterator: T)where T: IntoIterator<Item = Attribute>,
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)source§impl Flags for Attribute
impl Flags for Attribute
source§const FLAGS: &'static [Flag<Attribute>] = &[{ ::bitflags::Flag::new("BOLD", Attribute::BOLD) },
{ ::bitflags::Flag::new("DIM", Attribute::DIM) },
{ ::bitflags::Flag::new("ITALIC", Attribute::ITALIC) },
{ ::bitflags::Flag::new("UL", Attribute::UL) },
{ ::bitflags::Flag::new("BLINK", Attribute::BLINK) },
{ ::bitflags::Flag::new("REVERSE", Attribute::REVERSE) },
{ ::bitflags::Flag::new("STRIKE", Attribute::STRIKE) },
{ ::bitflags::Flag::new("RESET", Attribute::RESET) },
{ ::bitflags::Flag::new("NO_DIM", Attribute::NO_DIM) },
{ ::bitflags::Flag::new("NO_BOLD", Attribute::NO_BOLD) },
{ ::bitflags::Flag::new("NO_ITALIC", Attribute::NO_ITALIC) },
{ ::bitflags::Flag::new("NO_UL", Attribute::NO_UL) },
{ ::bitflags::Flag::new("NO_BLINK", Attribute::NO_BLINK) },
{ ::bitflags::Flag::new("NO_REVERSE", Attribute::NO_REVERSE) },
{ ::bitflags::Flag::new("NO_STRIKE", Attribute::NO_STRIKE) }]
const FLAGS: &'static [Flag<Attribute>] = &[{ ::bitflags::Flag::new("BOLD", Attribute::BOLD) }, { ::bitflags::Flag::new("DIM", Attribute::DIM) }, { ::bitflags::Flag::new("ITALIC", Attribute::ITALIC) }, { ::bitflags::Flag::new("UL", Attribute::UL) }, { ::bitflags::Flag::new("BLINK", Attribute::BLINK) }, { ::bitflags::Flag::new("REVERSE", Attribute::REVERSE) }, { ::bitflags::Flag::new("STRIKE", Attribute::STRIKE) }, { ::bitflags::Flag::new("RESET", Attribute::RESET) }, { ::bitflags::Flag::new("NO_DIM", Attribute::NO_DIM) }, { ::bitflags::Flag::new("NO_BOLD", Attribute::NO_BOLD) }, { ::bitflags::Flag::new("NO_ITALIC", Attribute::NO_ITALIC) }, { ::bitflags::Flag::new("NO_UL", Attribute::NO_UL) }, { ::bitflags::Flag::new("NO_BLINK", Attribute::NO_BLINK) }, { ::bitflags::Flag::new("NO_REVERSE", Attribute::NO_REVERSE) }, { ::bitflags::Flag::new("NO_STRIKE", Attribute::NO_STRIKE) }]
source§fn from_bits_retain(bits: u32) -> Attribute
fn from_bits_retain(bits: u32) -> Attribute
source§fn from_bits(bits: Self::Bits) -> Option<Self>
fn from_bits(bits: Self::Bits) -> Option<Self>
source§fn from_bits_truncate(bits: Self::Bits) -> Self
fn from_bits_truncate(bits: Self::Bits) -> Self
source§fn iter_names(&self) -> IterNames<Self>
fn iter_names(&self) -> IterNames<Self>
source§fn intersects(&self, other: Self) -> boolwhere
Self: Sized,
fn intersects(&self, other: Self) -> boolwhere Self: Sized,
true
if there are flags common to both self
and other
.source§fn contains(&self, other: Self) -> boolwhere
Self: Sized,
fn contains(&self, other: Self) -> boolwhere Self: Sized,
true
if all of the flags in other
are contained within self
.source§fn set(&mut self, other: Self, value: bool)where
Self: Sized,
fn set(&mut self, other: Self, value: bool)where Self: Sized,
source§fn intersection(self, other: Self) -> Self
fn intersection(self, other: Self) -> Self
source§fn difference(self, other: Self) -> Self
fn difference(self, other: Self) -> Self
source§fn symmetric_difference(self, other: Self) -> Self
fn symmetric_difference(self, other: Self) -> Self
source§fn complement(self) -> Self
fn complement(self) -> Self
source§impl FromIterator<Attribute> for Attribute
impl FromIterator<Attribute> for Attribute
source§impl IntoIterator for Attribute
impl IntoIterator for Attribute
source§impl Ord for Attribute
impl Ord for Attribute
source§impl PartialEq<Attribute> for Attribute
impl PartialEq<Attribute> for Attribute
source§impl PartialOrd<Attribute> for Attribute
impl PartialOrd<Attribute> for Attribute
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl Serialize for Attribute
Available on crate feature serde
only.
impl Serialize for Attribute
serde
only.source§fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>( &self, serializer: S ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where S: Serializer,
source§impl SubAssign<Attribute> for Attribute
impl SubAssign<Attribute> for Attribute
source§fn sub_assign(&mut self, other: Attribute)
fn sub_assign(&mut self, other: Attribute)
Disables all flags enabled in the set.