pub struct Input<M: Display> { /* private fields */ }
Expand description
Input
struct
§Examples
use may_clack::{cancel, input};
let answer = input("message")
.initial_value("initial_value")
.validate(|x| {
if x.find(char::is_uppercase).is_some() {
Err(Cow::Borrowed("only use lowercase characters"))
} else {
Ok(())
}
})
.cancel(do_cancel)
.interact()?;
println!("answer {:?}", answer);
fn do_cancel() {
cancel!("operation cancelled");
std::process::exit(1);
}
Implementations§
Source§impl<M: Display> Input<M>
impl<M: Display> Input<M>
Sourcepub fn placeholder<S: ToString>(&mut self, placeholder: S) -> &mut Self
pub fn placeholder<S: ToString>(&mut self, placeholder: S) -> &mut Self
Specify a placeholder.
§Examples
use may_clack::input;
let answer = input("message").placeholder("placeholder").required()?;
println!("answer {:?}", answer);
Examples found in repository?
examples/to_string.rs (line 18)
13fn main() -> Result<(), ClackError> {
14 println!();
15 intro!(" to_string ".reversed());
16
17 let int = input("int").initial_value(23).parse::<i32>()?;
18 let unit = input("struct").placeholder(Name).required()?;
19
20 outro!();
21
22 println!("int {:?}", int);
23 println!("unit {:?}", unit);
24
25 Ok(())
26}
More examples
examples/full.rs (line 14)
7fn main() -> Result<(), ClackError> {
8 println!();
9 intro!(" full ".reversed());
10
11 info!("visit the documentation at https://docs.rs/may-clack");
12
13 let do_input = input("input")
14 .placeholder("placeholder")
15 .cancel(do_cancel)
16 .required()?;
17 let do_multi_input = multi_input("multi input")
18 .max(4)
19 .cancel(do_cancel)
20 .interact()?;
21 let do_confirm = confirm("confirm")
22 .prompts("true", "false")
23 .cancel(do_cancel)
24 .interact()?;
25 let do_multi_select = multi_select("multi select")
26 .option("opt1", "option 1")
27 .option("opt2", "option 2")
28 .option_hint("opt3", "option 3", "hint")
29 .cancel(do_cancel)
30 .interact()?;
31 let do_select = select("select")
32 .option("val1", "value 1")
33 .option("val2", "value 2")
34 .option_hint("val 3", "value 3", "hint")
35 .cancel(do_cancel)
36 .interact()?;
37
38 outro!();
39
40 println!("input {:?}", do_input);
41 println!("confirm {:?}", do_confirm);
42 println!("multi_input {:?}", do_multi_input);
43 println!("multi_select {:?}", do_multi_select);
44 println!("select {:?}", do_select);
45
46 Ok(())
47}
Sourcepub fn maybe_initial<T: Borrow<Option<S>>, S: ToString>(
&mut self,
initial: T,
) -> &mut Self
pub fn maybe_initial<T: Borrow<Option<S>>, S: ToString>( &mut self, initial: T, ) -> &mut Self
Maybe specify an initial value.
§Examples
use may_clack::input;
let answer = input("message").maybe_initial(Some("initial")).required()?;
let answer = input("message").maybe_initial(None::<&str>).required()?;
Examples found in repository?
examples/maybe_initial.rs (line 12)
4fn main() -> Result<(), ClackError> {
5 println!();
6 intro!(" maybe_initial ".reversed());
7
8 let opt = Some("test");
9
10 #[allow(clippy::needless_borrows_for_generic_args)]
11 let ref_opt = input("message")
12 .maybe_initial(&opt)
13 .cancel(do_cancel)
14 .required()?;
15 let opt = input("message")
16 .maybe_initial(opt)
17 .cancel(do_cancel)
18 .required()?;
19 let none = input("message")
20 .maybe_initial(None::<&str>)
21 .cancel(do_cancel)
22 .required()?;
23
24 outro!();
25
26 println!("ref_opt {:?}", ref_opt);
27 println!("opt {:?}", opt);
28 println!("none {:?}", none);
29
30 Ok(())
31}
Sourcepub fn initial_value<S: ToString>(&mut self, initial_value: S) -> &mut Self
pub fn initial_value<S: ToString>(&mut self, initial_value: S) -> &mut Self
Specify the initial value.
§Examples
use may_clack::input;
let answer = input("message").initial_value("initial_value").interact()?;
println!("answer {:?}", answer);
Examples found in repository?
examples/to_string.rs (line 17)
13fn main() -> Result<(), ClackError> {
14 println!();
15 intro!(" to_string ".reversed());
16
17 let int = input("int").initial_value(23).parse::<i32>()?;
18 let unit = input("struct").placeholder(Name).required()?;
19
20 outro!();
21
22 println!("int {:?}", int);
23 println!("unit {:?}", unit);
24
25 Ok(())
26}
Sourcepub fn validate<F>(&mut self, validate: F) -> &mut Self
pub fn validate<F>(&mut self, validate: F) -> &mut Self
Specify a validation function.
On a successful validation, return a None
from the closure,
and on an unsuccessful validation return a Some<&'static str>
with the error message.
§Examples
use may_clack::input;
let answer = input("message")
.validate(|x| {
if x.is_ascii() {
Ok(())
} else {
Err(Cow::Borrowed("only use ascii characters"))
}
})
.interact()?;
println!("answer {:?}", answer);
Examples found in repository?
examples/validate.rs (lines 10-16)
5fn main() -> Result<(), ClackError> {
6 println!();
7 intro!(" validate ".reversed());
8
9 let do_validate_input = input("validate single (only use ascii)")
10 .validate(|x| {
11 if x.is_ascii() {
12 Ok(())
13 } else {
14 Err(Cow::Borrowed("only use ascii characters"))
15 }
16 })
17 .cancel(do_cancel)
18 .required()?;
19 let do_validate_multi_input = multi_input("validate multi (only use lowercase)")
20 .validate(|x| {
21 if x.find(char::is_uppercase).is_some() {
22 Err(Cow::Borrowed("only use lowercase characters"))
23 } else {
24 Ok(())
25 }
26 })
27 .cancel(do_cancel)
28 .interact()?;
29 let do_parse_input = input("parse to u8").cancel(do_cancel).parse::<u8>()?;
30 let do_maybe_parse = input("maybe parse to ipv4 addr").maybe_parse::<Ipv4Addr>()?;
31 let do_parse_multi = multi_input("parse multiple to u8")
32 .cancel(do_cancel)
33 .parse::<u8>()?;
34
35 outro!();
36
37 println!("single {:?}", do_validate_input);
38 println!("multi {:?}", do_validate_multi_input);
39 println!("parse single {:?}", do_parse_input);
40 println!("maybe parse single {:?}", do_maybe_parse);
41 println!("parse multi {:?}", do_parse_multi);
42
43 Ok(())
44}
Sourcepub fn cancel<F>(&mut self, cancel: F) -> &mut Selfwhere
F: Fn() + 'static,
pub fn cancel<F>(&mut self, cancel: F) -> &mut Selfwhere
F: Fn() + 'static,
Specify function to call on cancel.
§Examples
use may_clack::{input, cancel};
let answer = input("message").cancel(do_cancel).interact()?;
println!("answer {:?}", answer);
fn do_cancel() {
cancel!("operation cancelled");
panic!("operation cancelled");
}
Examples found in repository?
examples/maybe_initial.rs (line 13)
4fn main() -> Result<(), ClackError> {
5 println!();
6 intro!(" maybe_initial ".reversed());
7
8 let opt = Some("test");
9
10 #[allow(clippy::needless_borrows_for_generic_args)]
11 let ref_opt = input("message")
12 .maybe_initial(&opt)
13 .cancel(do_cancel)
14 .required()?;
15 let opt = input("message")
16 .maybe_initial(opt)
17 .cancel(do_cancel)
18 .required()?;
19 let none = input("message")
20 .maybe_initial(None::<&str>)
21 .cancel(do_cancel)
22 .required()?;
23
24 outro!();
25
26 println!("ref_opt {:?}", ref_opt);
27 println!("opt {:?}", opt);
28 println!("none {:?}", none);
29
30 Ok(())
31}
More examples
examples/full.rs (line 15)
7fn main() -> Result<(), ClackError> {
8 println!();
9 intro!(" full ".reversed());
10
11 info!("visit the documentation at https://docs.rs/may-clack");
12
13 let do_input = input("input")
14 .placeholder("placeholder")
15 .cancel(do_cancel)
16 .required()?;
17 let do_multi_input = multi_input("multi input")
18 .max(4)
19 .cancel(do_cancel)
20 .interact()?;
21 let do_confirm = confirm("confirm")
22 .prompts("true", "false")
23 .cancel(do_cancel)
24 .interact()?;
25 let do_multi_select = multi_select("multi select")
26 .option("opt1", "option 1")
27 .option("opt2", "option 2")
28 .option_hint("opt3", "option 3", "hint")
29 .cancel(do_cancel)
30 .interact()?;
31 let do_select = select("select")
32 .option("val1", "value 1")
33 .option("val2", "value 2")
34 .option_hint("val 3", "value 3", "hint")
35 .cancel(do_cancel)
36 .interact()?;
37
38 outro!();
39
40 println!("input {:?}", do_input);
41 println!("confirm {:?}", do_confirm);
42 println!("multi_input {:?}", do_multi_input);
43 println!("multi_select {:?}", do_multi_select);
44 println!("select {:?}", do_select);
45
46 Ok(())
47}
examples/validate.rs (line 17)
5fn main() -> Result<(), ClackError> {
6 println!();
7 intro!(" validate ".reversed());
8
9 let do_validate_input = input("validate single (only use ascii)")
10 .validate(|x| {
11 if x.is_ascii() {
12 Ok(())
13 } else {
14 Err(Cow::Borrowed("only use ascii characters"))
15 }
16 })
17 .cancel(do_cancel)
18 .required()?;
19 let do_validate_multi_input = multi_input("validate multi (only use lowercase)")
20 .validate(|x| {
21 if x.find(char::is_uppercase).is_some() {
22 Err(Cow::Borrowed("only use lowercase characters"))
23 } else {
24 Ok(())
25 }
26 })
27 .cancel(do_cancel)
28 .interact()?;
29 let do_parse_input = input("parse to u8").cancel(do_cancel).parse::<u8>()?;
30 let do_maybe_parse = input("maybe parse to ipv4 addr").maybe_parse::<Ipv4Addr>()?;
31 let do_parse_multi = multi_input("parse multiple to u8")
32 .cancel(do_cancel)
33 .parse::<u8>()?;
34
35 outro!();
36
37 println!("single {:?}", do_validate_input);
38 println!("multi {:?}", do_validate_multi_input);
39 println!("parse single {:?}", do_parse_input);
40 println!("maybe parse single {:?}", do_maybe_parse);
41 println!("parse multi {:?}", do_parse_multi);
42
43 Ok(())
44}
Sourcepub fn parse<T: FromStr + Display>(&self) -> Result<T, ClackError>
pub fn parse<T: FromStr + Display>(&self) -> Result<T, ClackError>
Like Input::required()
, but parses the value before returning.
Useful for getting number inputs.
§Examples
use may_clack::input;
let answer: i32 = input("message").parse::<i32>()?;
println!("answer {:?}", answer);
Examples found in repository?
examples/to_string.rs (line 17)
13fn main() -> Result<(), ClackError> {
14 println!();
15 intro!(" to_string ".reversed());
16
17 let int = input("int").initial_value(23).parse::<i32>()?;
18 let unit = input("struct").placeholder(Name).required()?;
19
20 outro!();
21
22 println!("int {:?}", int);
23 println!("unit {:?}", unit);
24
25 Ok(())
26}
More examples
examples/validate.rs (line 29)
5fn main() -> Result<(), ClackError> {
6 println!();
7 intro!(" validate ".reversed());
8
9 let do_validate_input = input("validate single (only use ascii)")
10 .validate(|x| {
11 if x.is_ascii() {
12 Ok(())
13 } else {
14 Err(Cow::Borrowed("only use ascii characters"))
15 }
16 })
17 .cancel(do_cancel)
18 .required()?;
19 let do_validate_multi_input = multi_input("validate multi (only use lowercase)")
20 .validate(|x| {
21 if x.find(char::is_uppercase).is_some() {
22 Err(Cow::Borrowed("only use lowercase characters"))
23 } else {
24 Ok(())
25 }
26 })
27 .cancel(do_cancel)
28 .interact()?;
29 let do_parse_input = input("parse to u8").cancel(do_cancel).parse::<u8>()?;
30 let do_maybe_parse = input("maybe parse to ipv4 addr").maybe_parse::<Ipv4Addr>()?;
31 let do_parse_multi = multi_input("parse multiple to u8")
32 .cancel(do_cancel)
33 .parse::<u8>()?;
34
35 outro!();
36
37 println!("single {:?}", do_validate_input);
38 println!("multi {:?}", do_validate_multi_input);
39 println!("parse single {:?}", do_parse_input);
40 println!("maybe parse single {:?}", do_maybe_parse);
41 println!("parse multi {:?}", do_parse_multi);
42
43 Ok(())
44}
Sourcepub fn maybe_parse<T: FromStr + Display>(&self) -> Result<Option<T>, ClackError>
pub fn maybe_parse<T: FromStr + Display>(&self) -> Result<Option<T>, ClackError>
Like Input::parse()
, but it also allows empty line submits like Input::interact()
.
use may_clack::input;
use std::net::Ipv4Addr;
let answer = input("message").maybe_parse::<Ipv4Addr>()?;
println!("answer {:?}", answer);
Examples found in repository?
examples/validate.rs (line 30)
5fn main() -> Result<(), ClackError> {
6 println!();
7 intro!(" validate ".reversed());
8
9 let do_validate_input = input("validate single (only use ascii)")
10 .validate(|x| {
11 if x.is_ascii() {
12 Ok(())
13 } else {
14 Err(Cow::Borrowed("only use ascii characters"))
15 }
16 })
17 .cancel(do_cancel)
18 .required()?;
19 let do_validate_multi_input = multi_input("validate multi (only use lowercase)")
20 .validate(|x| {
21 if x.find(char::is_uppercase).is_some() {
22 Err(Cow::Borrowed("only use lowercase characters"))
23 } else {
24 Ok(())
25 }
26 })
27 .cancel(do_cancel)
28 .interact()?;
29 let do_parse_input = input("parse to u8").cancel(do_cancel).parse::<u8>()?;
30 let do_maybe_parse = input("maybe parse to ipv4 addr").maybe_parse::<Ipv4Addr>()?;
31 let do_parse_multi = multi_input("parse multiple to u8")
32 .cancel(do_cancel)
33 .parse::<u8>()?;
34
35 outro!();
36
37 println!("single {:?}", do_validate_input);
38 println!("multi {:?}", do_validate_multi_input);
39 println!("parse single {:?}", do_parse_input);
40 println!("maybe parse single {:?}", do_maybe_parse);
41 println!("parse multi {:?}", do_parse_multi);
42
43 Ok(())
44}
Sourcepub fn required(&self) -> Result<String, ClackError>
pub fn required(&self) -> Result<String, ClackError>
Like Input::interact()
, but does not return an empty line.
§Examples
use may_clack::input;
let answer = input("message").required()?;
println!("answer {:?}", answer);
Examples found in repository?
examples/to_string.rs (line 18)
13fn main() -> Result<(), ClackError> {
14 println!();
15 intro!(" to_string ".reversed());
16
17 let int = input("int").initial_value(23).parse::<i32>()?;
18 let unit = input("struct").placeholder(Name).required()?;
19
20 outro!();
21
22 println!("int {:?}", int);
23 println!("unit {:?}", unit);
24
25 Ok(())
26}
More examples
examples/maybe_initial.rs (line 14)
4fn main() -> Result<(), ClackError> {
5 println!();
6 intro!(" maybe_initial ".reversed());
7
8 let opt = Some("test");
9
10 #[allow(clippy::needless_borrows_for_generic_args)]
11 let ref_opt = input("message")
12 .maybe_initial(&opt)
13 .cancel(do_cancel)
14 .required()?;
15 let opt = input("message")
16 .maybe_initial(opt)
17 .cancel(do_cancel)
18 .required()?;
19 let none = input("message")
20 .maybe_initial(None::<&str>)
21 .cancel(do_cancel)
22 .required()?;
23
24 outro!();
25
26 println!("ref_opt {:?}", ref_opt);
27 println!("opt {:?}", opt);
28 println!("none {:?}", none);
29
30 Ok(())
31}
examples/full.rs (line 16)
7fn main() -> Result<(), ClackError> {
8 println!();
9 intro!(" full ".reversed());
10
11 info!("visit the documentation at https://docs.rs/may-clack");
12
13 let do_input = input("input")
14 .placeholder("placeholder")
15 .cancel(do_cancel)
16 .required()?;
17 let do_multi_input = multi_input("multi input")
18 .max(4)
19 .cancel(do_cancel)
20 .interact()?;
21 let do_confirm = confirm("confirm")
22 .prompts("true", "false")
23 .cancel(do_cancel)
24 .interact()?;
25 let do_multi_select = multi_select("multi select")
26 .option("opt1", "option 1")
27 .option("opt2", "option 2")
28 .option_hint("opt3", "option 3", "hint")
29 .cancel(do_cancel)
30 .interact()?;
31 let do_select = select("select")
32 .option("val1", "value 1")
33 .option("val2", "value 2")
34 .option_hint("val 3", "value 3", "hint")
35 .cancel(do_cancel)
36 .interact()?;
37
38 outro!();
39
40 println!("input {:?}", do_input);
41 println!("confirm {:?}", do_confirm);
42 println!("multi_input {:?}", do_multi_input);
43 println!("multi_select {:?}", do_multi_select);
44 println!("select {:?}", do_select);
45
46 Ok(())
47}
examples/validate.rs (line 18)
5fn main() -> Result<(), ClackError> {
6 println!();
7 intro!(" validate ".reversed());
8
9 let do_validate_input = input("validate single (only use ascii)")
10 .validate(|x| {
11 if x.is_ascii() {
12 Ok(())
13 } else {
14 Err(Cow::Borrowed("only use ascii characters"))
15 }
16 })
17 .cancel(do_cancel)
18 .required()?;
19 let do_validate_multi_input = multi_input("validate multi (only use lowercase)")
20 .validate(|x| {
21 if x.find(char::is_uppercase).is_some() {
22 Err(Cow::Borrowed("only use lowercase characters"))
23 } else {
24 Ok(())
25 }
26 })
27 .cancel(do_cancel)
28 .interact()?;
29 let do_parse_input = input("parse to u8").cancel(do_cancel).parse::<u8>()?;
30 let do_maybe_parse = input("maybe parse to ipv4 addr").maybe_parse::<Ipv4Addr>()?;
31 let do_parse_multi = multi_input("parse multiple to u8")
32 .cancel(do_cancel)
33 .parse::<u8>()?;
34
35 outro!();
36
37 println!("single {:?}", do_validate_input);
38 println!("multi {:?}", do_validate_multi_input);
39 println!("parse single {:?}", do_parse_input);
40 println!("maybe parse single {:?}", do_maybe_parse);
41 println!("parse multi {:?}", do_parse_multi);
42
43 Ok(())
44}
Sourcepub fn interact(&self) -> Result<Option<String>, ClackError>
pub fn interact(&self) -> Result<Option<String>, ClackError>
Waits for the user to submit a line of text.
Returns None
on an empty line and Some::<String>
otherwise.
§Examples
use may_clack::{cancel, input};
let answer = input("message")
.initial_value("initial_value")
.validate(|x| {
x.parse::<u32>()
.map(|_| ())
.map_err(|_| Cow::Borrowed("invalid u32"))
})
.cancel(do_cancel)
.interact()?;
println!("answer {:?}", answer);
fn do_cancel() {
cancel!("operation cancelled");
std::process::exit(1);
}
Auto Trait Implementations§
impl<M> Freeze for Input<M>where
M: Freeze,
impl<M> !RefUnwindSafe for Input<M>
impl<M> !Send for Input<M>
impl<M> !Sync for Input<M>
impl<M> Unpin for Input<M>where
M: Unpin,
impl<M> !UnwindSafe for Input<M>
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Set the foreground color generically Read more
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Set the background color generically. Read more
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Change the foreground color to black
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Change the background color to black
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Change the foreground color to red
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Change the background color to red
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Change the foreground color to green
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Change the background color to green
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Change the foreground color to yellow
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Change the background color to yellow
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Change the foreground color to blue
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Change the background color to blue
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Change the foreground color to magenta
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Change the background color to magenta
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Change the foreground color to purple
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Change the background color to purple
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Change the foreground color to cyan
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Change the background color to cyan
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Change the foreground color to white
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Change the background color to white
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Change the foreground color to the terminal default
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Change the background color to the terminal default
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Change the foreground color to bright black
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Change the background color to bright black
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Change the foreground color to bright red
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Change the background color to bright red
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Change the foreground color to bright green
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Change the background color to bright green
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Change the foreground color to bright yellow
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Change the background color to bright yellow
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Change the foreground color to bright blue
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Change the background color to bright blue
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Change the foreground color to bright magenta
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Change the background color to bright magenta
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Change the foreground color to bright purple
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Change the background color to bright purple
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Change the foreground color to bright cyan
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Change the background color to bright cyan
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Change the foreground color to bright white
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Change the background color to bright white
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Make the text bold
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Make the text dim
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Make the text italicized
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Make the text underlined
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Make the text blink
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Make the text blink (but fast!)
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Swap the foreground and background colors
Hide the text
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Cross out the text
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
Set the foreground color at runtime. Only use if you do not know which color will be used at
compile-time. If the color is constant, use either
OwoColorize::fg
or
a color-specific method, such as OwoColorize::green
, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
Set the background color at runtime. Only use if you do not know what color to use at
compile-time. If the color is constant, use either
OwoColorize::bg
or
a color-specific method, such as OwoColorize::on_yellow
, Read moreSource§fn fg_rgb<const R: u8, const G: u8, const B: u8>(
&self,
) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>
fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>
Set the foreground color to a specific RGB value.
Source§fn bg_rgb<const R: u8, const G: u8, const B: u8>(
&self,
) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>
fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>
Set the background color to a specific RGB value.
Source§fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>
fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>
Sets the foreground color to an RGB value.
Source§fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>
fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>
Sets the background color to an RGB value.