Skip to main content

ThemeColor

Struct ThemeColor 

Source
pub struct ThemeColor {
    pub rgb: (u8, u8, u8),
    pub ansi256: u8,
    pub plain_marker: Option<&'static str>,
}
Expand description

A color that can be rendered differently based on output mode.

Contains both truecolor RGB and ANSI-256 fallback values, plus an optional plain text marker for non-color output.

Fields§

§rgb: (u8, u8, u8)

RGB color for truecolor terminals (r, g, b).

§ansi256: u8

ANSI 256-color fallback for older terminals.

§plain_marker: Option<&'static str>

Plain text marker (for plain mode output), e.g., “NULL” for null values.

Implementations§

Source§

impl ThemeColor

Source

pub const fn new(rgb: (u8, u8, u8), ansi256: u8) -> Self

Create a theme color with RGB and ANSI-256 fallback.

§Example
use sqlmodel_console::theme::ThemeColor;

let green = ThemeColor::new((80, 250, 123), 84);
Source

pub const fn with_marker( rgb: (u8, u8, u8), ansi256: u8, marker: &'static str, ) -> Self

Create a theme color with a plain text marker.

The marker is used in plain mode to indicate special values like NULL without using colors.

§Example
use sqlmodel_console::theme::ThemeColor;

let null_color = ThemeColor::with_marker((98, 114, 164), 60, "NULL");
Source

pub const fn rgb(&self) -> (u8, u8, u8)

Get the RGB components as a tuple.

Source

pub const fn ansi256(&self) -> u8

Get the ANSI-256 color code.

Source

pub const fn plain_marker(&self) -> Option<&'static str>

Get the plain text marker, if any.

Source

pub fn color_code(&self) -> String

Get a truecolor ANSI escape sequence for this color.

Returns a string like \x1b[38;2;R;G;Bm for foreground color.

Trait Implementations§

Source§

impl Clone for ThemeColor

Source§

fn clone(&self) -> ThemeColor

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for ThemeColor

Source§

impl Debug for ThemeColor

Source§

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

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

impl Eq for ThemeColor

Source§

impl PartialEq for ThemeColor

Source§

fn eq(&self, other: &ThemeColor) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ThemeColor

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