rust-colors 0.2.0

A library for parsing ANSI Strings to colors.
Documentation

rust-colors

A library for parsing ANSI Strings to colors. Built in Rust, open source and easy to use. Underneath are some examples of how you could use the functions.

You can reach out to me on Discord: RedIsGaming

Example color functions main program

Here is an example of how the main program can look:

use rust_colors::{Ansi, Color, Colors};

fn main() {
    let colors = Ansi;

    println!(
        "The sky is {}, apples can be {}, do you like to touch {} grass?",
        colors.color("blue", Colors::Blue),
        colors.bold_color("red", Colors::Red),
        colors.underline_color("green", Colors::Green),
    );
}

Author

RedIsGaming

Language(s) and tools

  • Rust
  • VSCode
    • rust-analyzer (extension)
    • Even Better TOML (extension)
    • Error Lens (extension)
    • crates (extension)
  • Cargo
    • clippy (feature)
    • fmt (feature)

License

MIT license

Status

Contact

Discord

How to use this project?

How to run?

First clone the rust-colors project to any location you desire.

git clone https://github.com/RedIsGaming/rust-colors.git

Then switch to that directory and run Cargo.

cd rust-colors
cargo run

Color functions rust-colors(ANSI)

Here is a quick overview of functions that are applied for this project:

Struct

#[derive(Debug)]
pub struct Ansi;

Trait

pub trait Color<T: fmt::Debug> {
    type Transform;
}

Trait functions

//Required functions:
fn color(&self, txt: T, color: Colors) -> Self::Transform;
fn bold_color(&self, txt: T, bold_color: Colors) -> Self::Transform;
fn underline_color(&self, txt: T, underline_color: Colors) -> Self::Transform;