pub enum ColorChoice {
Auto,
Always,
Never,
}Expand description
User preference for emitting ANSI color escape codes.
Variants§
Auto
Automatically enable color if writing to a TTY and environment allows it.
Always
Always emit ANSI color codes, even when redirected or piped.
Never
Never emit ANSI color codes.
Implementations§
Source§impl ColorChoice
impl ColorChoice
Sourcepub fn should_color(self, is_terminal: bool) -> bool
pub fn should_color(self, is_terminal: bool) -> bool
Determine whether color should be active given the terminal/TTY status of the output.
Respects:
NO_COLOR(https://no-color.org)FORCE_COLOR(https://force-color.org)TERM=dumb- Stream TTY status
Sourcepub fn detect_auto(is_terminal: bool) -> bool
pub fn detect_auto(is_terminal: bool) -> bool
Automatically detect whether color is supported for the current environment.
Sourcepub fn detect_with(
is_terminal: bool,
get_var: impl Fn(&str) -> Option<String>,
) -> bool
pub fn detect_with( is_terminal: bool, get_var: impl Fn(&str) -> Option<String>, ) -> bool
Internal helper that tests environment variables using a mockable lookup closure.
Sourcepub fn resolve_stdout(self) -> bool
pub fn resolve_stdout(self) -> bool
Resolve whether stdout should currently display colors.
Sourcepub fn resolve_stderr(self) -> bool
pub fn resolve_stderr(self) -> bool
Resolve whether stderr should currently display colors.
Trait Implementations§
Source§impl Clone for ColorChoice
impl Clone for ColorChoice
Source§fn clone(&self) -> ColorChoice
fn clone(&self) -> ColorChoice
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for ColorChoice
Source§impl Debug for ColorChoice
impl Debug for ColorChoice
Source§impl Default for ColorChoice
impl Default for ColorChoice
Source§fn default() -> ColorChoice
fn default() -> ColorChoice
Returns the “default value” for a type. Read more
impl Eq for ColorChoice
Source§impl PartialEq for ColorChoice
impl PartialEq for ColorChoice
impl StructuralPartialEq for ColorChoice
Auto Trait Implementations§
impl Freeze for ColorChoice
impl RefUnwindSafe for ColorChoice
impl Send for ColorChoice
impl Sync for ColorChoice
impl Unpin for ColorChoice
impl UnsafeUnpin for ColorChoice
impl UnwindSafe for ColorChoice
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more