pub struct FormattingOptions { /* private fields */ }
formatting_options
)Expand description
Implementationsยง
Sourceยงimpl FormattingOptions
impl FormattingOptions
Sourcepub const fn new() -> FormattingOptions
๐ฌThis is a nightly-only experimental API. (formatting_options
)
pub const fn new() -> FormattingOptions
formatting_options
)Construct a new FormatterBuilder
with the supplied Write
trait
object for output that is equivalent to the {}
formatting
specifier:
- no flags,
- filled with spaces,
- no alignment,
- no width,
- no precision, and
- no
DebugAsHex
output mode.
Sourcepub fn sign(&mut self, sign: Option<Sign>) -> &mut FormattingOptions
๐ฌThis is a nightly-only experimental API. (formatting_options
)
pub fn sign(&mut self, sign: Option<Sign>) -> &mut FormattingOptions
formatting_options
)Sets or removes the sign (the +
or the -
flag).
+
: This is intended for numeric types and indicates that the sign should always be printed. By default only the negative sign of signed values is printed, and the sign of positive or unsigned values is omitted. This flag indicates that the correct sign (+ or -) should always be printed.-
: Currently not used
Sourcepub fn sign_aware_zero_pad(
&mut self,
sign_aware_zero_pad: bool,
) -> &mut FormattingOptions
๐ฌThis is a nightly-only experimental API. (formatting_options
)
pub fn sign_aware_zero_pad( &mut self, sign_aware_zero_pad: bool, ) -> &mut FormattingOptions
formatting_options
)Sets or unsets the 0
flag.
This is used to indicate for integer formats that the padding to width should both be done with a 0 character as well as be sign-aware
Sourcepub fn alternate(&mut self, alternate: bool) -> &mut FormattingOptions
๐ฌThis is a nightly-only experimental API. (formatting_options
)
pub fn alternate(&mut self, alternate: bool) -> &mut FormattingOptions
formatting_options
)Sets or unsets the #
flag.
This flag indicates that the โalternateโ form of printing should be used. The alternate forms are:
Sourcepub fn fill(&mut self, fill: char) -> &mut FormattingOptions
๐ฌThis is a nightly-only experimental API. (formatting_options
)
pub fn fill(&mut self, fill: char) -> &mut FormattingOptions
formatting_options
)Sets the fill character.
The optional fill character and alignment is provided normally in conjunction with the width parameter. This indicates that if the value being formatted is smaller than width some extra characters will be printed around it.
Sourcepub fn align(&mut self, align: Option<Alignment>) -> &mut FormattingOptions
๐ฌThis is a nightly-only experimental API. (formatting_options
)
pub fn align(&mut self, align: Option<Alignment>) -> &mut FormattingOptions
formatting_options
)Sets or removes the alignment.
The alignment specifies how the value being formatted should be positioned if it is smaller than the width of the formatter.
Sourcepub fn width(&mut self, width: Option<u16>) -> &mut FormattingOptions
๐ฌThis is a nightly-only experimental API. (formatting_options
)
pub fn width(&mut self, width: Option<u16>) -> &mut FormattingOptions
formatting_options
)Sets or removes the width.
This is a parameter for the โminimum widthโ that the format should take
up. If the valueโs string does not fill up this many characters, then
the padding specified by FormattingOptions::fill
/FormattingOptions::align
will be used to take up the required space.
Sourcepub fn precision(&mut self, precision: Option<u16>) -> &mut FormattingOptions
๐ฌThis is a nightly-only experimental API. (formatting_options
)
pub fn precision(&mut self, precision: Option<u16>) -> &mut FormattingOptions
formatting_options
)Sets or removes the precision.
- For non-numeric types, this can be considered a โmaximum widthโ. If the resulting string is longer than this width, then it is truncated down to this many characters and that truncated value is emitted with proper fill, alignment and width if those parameters are set.
- For integral types, this is ignored.
- For floating-point types, this indicates how many digits after the decimal point should be printed.
Sourcepub fn debug_as_hex(
&mut self,
debug_as_hex: Option<DebugAsHex>,
) -> &mut FormattingOptions
๐ฌThis is a nightly-only experimental API. (formatting_options
)
pub fn debug_as_hex( &mut self, debug_as_hex: Option<DebugAsHex>, ) -> &mut FormattingOptions
formatting_options
)Specifies whether the Debug
trait should use lower-/upper-case
hexadecimal or normal integers
Sourcepub const fn get_sign(&self) -> Option<Sign>
๐ฌThis is a nightly-only experimental API. (formatting_options
)
pub const fn get_sign(&self) -> Option<Sign>
formatting_options
)Returns the current sign (the +
or the -
flag).
Sourcepub const fn get_sign_aware_zero_pad(&self) -> bool
๐ฌThis is a nightly-only experimental API. (formatting_options
)
pub const fn get_sign_aware_zero_pad(&self) -> bool
formatting_options
)Returns the current 0
flag.
Sourcepub const fn get_alternate(&self) -> bool
๐ฌThis is a nightly-only experimental API. (formatting_options
)
pub const fn get_alternate(&self) -> bool
formatting_options
)Returns the current #
flag.
Sourcepub const fn get_fill(&self) -> char
๐ฌThis is a nightly-only experimental API. (formatting_options
)
pub const fn get_fill(&self) -> char
formatting_options
)Returns the current fill character.
Sourcepub const fn get_align(&self) -> Option<Alignment>
๐ฌThis is a nightly-only experimental API. (formatting_options
)
pub const fn get_align(&self) -> Option<Alignment>
formatting_options
)Returns the current alignment.
Sourcepub const fn get_width(&self) -> Option<u16>
๐ฌThis is a nightly-only experimental API. (formatting_options
)
pub const fn get_width(&self) -> Option<u16>
formatting_options
)Returns the current width.
Sourcepub const fn get_precision(&self) -> Option<u16>
๐ฌThis is a nightly-only experimental API. (formatting_options
)
pub const fn get_precision(&self) -> Option<u16>
formatting_options
)Returns the current precision.
Sourcepub const fn get_debug_as_hex(&self) -> Option<DebugAsHex>
๐ฌThis is a nightly-only experimental API. (formatting_options
)
pub const fn get_debug_as_hex(&self) -> Option<DebugAsHex>
formatting_options
)Returns the current precision.
Sourcepub fn create_formatter<'a>(self, write: &'a mut dyn Write) -> Formatter<'a>
๐ฌThis is a nightly-only experimental API. (formatting_options
)
pub fn create_formatter<'a>(self, write: &'a mut dyn Write) -> Formatter<'a>
formatting_options
)Creates a Formatter
that writes its output to the given Write
trait.
You may alternatively use Formatter::new()
.
Trait Implementationsยง
Sourceยงimpl Clone for FormattingOptions
impl Clone for FormattingOptions
Sourceยงfn clone(&self) -> FormattingOptions
fn clone(&self) -> FormattingOptions
1.0.0 ยท Sourceยงfn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSourceยงimpl Debug for FormattingOptions
impl Debug for FormattingOptions
Sourceยงimpl Default for FormattingOptions
impl Default for FormattingOptions
Sourceยงfn default() -> FormattingOptions
fn default() -> FormattingOptions
Same as FormattingOptions::new()
.
Sourceยงimpl PartialEq for FormattingOptions
impl PartialEq for FormattingOptions
impl Copy for FormattingOptions
impl Eq for FormattingOptions
impl StructuralPartialEq for FormattingOptions
Auto Trait Implementationsยง
impl Freeze for FormattingOptions
impl RefUnwindSafe for FormattingOptions
impl Send for FormattingOptions
impl Sync for FormattingOptions
impl Unpin for FormattingOptions
impl UnwindSafe for FormattingOptions
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
Sourceยงimpl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Sourceยงimpl<T> OrAssignment for Twhere
T: Default,
impl<T> OrAssignment for Twhere
T: Default,
Sourceยงimpl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Sourceยงfn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self
with the foreground set to
value
.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red()
and
green()
, which have the same functionality but are
pithier.
ยงExample
Set foreground color to white using fg()
:
use yansi::{Paint, Color};
painted.fg(Color::White);
Set foreground color to white using white()
.
use yansi::Paint;
painted.white();
Sourceยงfn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Sourceยงfn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Sourceยงfn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Sourceยงfn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Sourceยงfn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Sourceยงfn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Sourceยงfn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Sourceยงfn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Sourceยงfn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self
with the background set to
value
.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red()
and
on_green()
, which have the same functionality but
are pithier.
ยงExample
Set background color to red using fg()
:
use yansi::{Paint, Color};
painted.bg(Color::Red);
Set background color to red using on_red()
.
use yansi::Paint;
painted.on_red();
Sourceยงfn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Sourceยงfn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Sourceยงfn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Sourceยงfn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Sourceยงfn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Sourceยงfn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Sourceยงfn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Sourceยงfn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Sourceยงfn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Sourceยงfn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Sourceยงfn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute
value
.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold()
and
underline()
, which have the same functionality
but are pithier.
ยงExample
Make text bold using attr()
:
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);
Make text bold using using bold()
.
use yansi::Paint;
painted.bold();
Sourceยงfn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Sourceยงfn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi
Quirk
value
.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask()
and
wrap()
, which have the same functionality but are
pithier.
ยงExample
Enable wrapping using .quirk()
:
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);
Enable wrapping using wrap()
.
use yansi::Paint;
painted.wrap();
Sourceยงfn clear(&self) -> Painted<&T>
๐Deprecated since 1.0.1: renamed to resetting()
due to conflicts with Vec::clear()
.
The clear()
method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting()
due to conflicts with Vec::clear()
.
The clear()
method will be removed in a future release.Sourceยงfn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition
value
applies. Replaces any previous condition.
See the crate level docs for more details.
ยงExample
Enable styling painted
only when both stdout
and stderr
are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);
Sourceยงimpl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Sourceยงfn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read moreSourceยงfn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).Sourceยงfn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.Sourceยงfn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.