ColorInitStrategy

Enum ColorInitStrategy 

Source
#[non_exhaustive]
pub enum ColorInitStrategy { Configure(ColorSupport, TermBgLuma, Option<[u8; 3]>), Default, Match, }
Expand description

Strategies for initializing terminal color attributes and theme selection

This enum defines different approaches for determining the appropriate color support and theme based on terminal capabilities, configuration, or defaults.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Configure(ColorSupport, TermBgLuma, Option<[u8; 3]>)

Use explicitly configured color support, background luminance, and optional background RGB

Parameters:

  • ColorSupport: The configured color support level
  • TermBgLuma: The configured background luminance (light/dark)
  • Option<[u8; 3]>: Optional RGB values for the background color
§

Default

Use safe default values without detection or configuration

Falls back to basic color support with dark background theme

§

Match

Automatically detect terminal capabilities and match appropriate theme

Uses terminal detection to determine color support and background luminance, then selects the best matching theme

Implementations§

Source§

impl ColorInitStrategy

Source

pub fn determine() -> Self

Determines the appropriate color initialization strategy based on available features and configuration.

This method evaluates the current environment and available features to select the most appropriate strategy for initializing terminal color attributes:

  • With color_detect feature: Uses auto-detection unless in test environment
  • With config feature only: Uses configuration values or falls back to defaults
  • Neither feature: Always uses safe defaults
§Returns

A static reference to the determined ColorInitStrategy

§Behavior
  • In test environments (TEST_ENV set): Always returns Default strategy
  • On Windows with color_detect: Uses Configure strategy with detected values
  • Other platforms with color_detect: Uses Match strategy for auto-detection
  • With config only: Uses Configure or Match based on configuration completeness
  • No features: Uses Default strategy

Trait Implementations§

Source§

impl Clone for ColorInitStrategy

Source§

fn clone(&self) -> ColorInitStrategy

Returns a duplicate 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 ColorInitStrategy

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> Any for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Source§

fn type_name(&self) -> &'static str

Source§

impl<T> AnySync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.