Struct OutputBuilder

Source
pub struct OutputBuilder<'a> {
    pub output: Output<'a>,
}
Expand description

OutputBuilder struct

Official Documentation,

§Code Example

§Using the OutputBuilder

§Using the output Function

use color_output::*;
output(
    OutputBuilder::new_from(Output::default())
        .text("test_output_builder")
        .color(ColorType::Color256(0xffffff))
        .bg_color(ColorType::Color256(0xffffff))
        .blod(true)
        .endl(true)
        .build(),
);

§Using the output Method

use color_output::*;
OutputBuilder::new()
    .text("test_output_builder_output")
    .bg_color(ColorType::Color256(0xffffff))
    .color(ColorType::Color256(0xffffff))
    .blod(true)
    .endl(true)
    .build()
    .output();

Fields§

§output: Output<'a>

Implementations§

Source§

impl<'a> OutputBuilder<'a>

Source

pub fn new() -> OutputBuilder<'a>

Creates the struct

§Returns
  • OutputBuilder: Output
Source

pub fn new_from(output: Output<'a>) -> OutputBuilder<'a>

Creates the struct from output

§Returns
  • OutputBuilder: Output
Source

pub fn text(&mut self, text: &'a str) -> &mut OutputBuilder<'a>

Sets the text.

§Parameters
  • text: The text to be set.
§Returns
  • &mut Self: A mutable reference to the struct for method chaining.
Source

pub fn color(&mut self, color: ColorType) -> &mut OutputBuilder<'a>

Sets the text color.

§Parameters
  • color: The color to be set for the text.
§Returns
  • &mut Self: A mutable reference to the struct for method chaining.
Source

pub fn bg_color(&mut self, bg_color: ColorType) -> &mut OutputBuilder<'a>

Sets the background color for the text.

§Parameters
  • bg_color: The background color to be set for the text.
§Returns
  • &mut Self: A mutable reference to the struct for method chaining.
Source

pub fn blod(&mut self, blod: bool) -> &mut OutputBuilder<'a>

Sets whether the text should be bold.

§Parameters
  • blod: A boolean indicating whether the text should be bold.
§Returns
  • &mut Self: A mutable reference to the struct for method chaining.
Source

pub fn endl(&mut self, endl: bool) -> &mut OutputBuilder<'a>

Sets the endl value for the Output.

§Parameters
  • endl: A boolean value that determines whether to add a newline at the end.
§Returns
  • &mut Self: Returns a mutable reference to the current Output instance, allowing method chaining.
Source

pub fn build(&self) -> Output<'_>

Builds and returns the Output struct.

§Returns
  • Output: The constructed Output struct.
Source

pub fn output(&self)

Outputs the current state of the Output struct.

§Returns
  • () : Nothing is returned.

Auto Trait Implementations§

§

impl<'a> Freeze for OutputBuilder<'a>

§

impl<'a> RefUnwindSafe for OutputBuilder<'a>

§

impl<'a> Send for OutputBuilder<'a>

§

impl<'a> Sync for OutputBuilder<'a>

§

impl<'a> Unpin for OutputBuilder<'a>

§

impl<'a> UnwindSafe for OutputBuilder<'a>

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