pub struct OutputListBuilder<'a> {
pub output_list: Vec<Output<'a>>,
}
Expand description
OutputListBuilder struct
§Code Example
§Using the OutputBuilder
use color_output::*;
OutputListBuilder::new_from(vec![Output::default()])
.add(
OutputBuilder::new()
.text("text")
.bg_color(ColorType::Use(Color::Blue))
.endl(false)
.build(),
)
.add(Output {
text: "test_new_from_output_list_builder_1",
color: ColorType::Use(Color::Default),
bg_color: ColorType::Color256(0x3f3f3f),
endl: false,
..Default::default()
})
.add(Output {
text: "test_new_from_output_list_builder_2",
color: ColorType::Use(Color::Default),
bg_color: ColorType::Use(Color::Cyan),
endl: true,
..Default::default()
})
.run();
Fields§
§output_list: Vec<Output<'a>>
A list of output structures.
Implementations§
Source§impl<'a> OutputListBuilder<'a>
impl<'a> OutputListBuilder<'a>
Sourcepub fn new() -> OutputListBuilder<'a>
pub fn new() -> OutputListBuilder<'a>
Creates a new empty OutputListBuilder
.
§Returns
Self
: A new instance ofOutputListBuilder
with an empty output list.
Sourcepub fn new_from(output_list: Vec<Output<'a>>) -> OutputListBuilder<'a>
pub fn new_from(output_list: Vec<Output<'a>>) -> OutputListBuilder<'a>
Sourcepub fn add(&mut self, output: Output<'a>) -> &mut OutputListBuilder<'a>
pub fn add(&mut self, output: Output<'a>) -> &mut OutputListBuilder<'a>
Sourcepub fn remove(&mut self, idx: usize) -> &mut OutputListBuilder<'a>
pub fn remove(&mut self, idx: usize) -> &mut OutputListBuilder<'a>
Removes an output item from the list at the specified index.
§Parameters
&mut self
: A mutable reference to the current instance ofOutputListBuilder
.idx
: The index of the output item to be removed.
§Returns
&mut Self
: A mutable reference to the current instance, allowing for method chaining.
If the index is out of bounds, the list remains unchanged.
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Clears all output items from the output list.
§Parameters
&mut self
: A mutable reference to the current instance ofOutputListBuilder
.
Sourcepub fn run(&mut self) -> &mut OutputListBuilder<'a>
pub fn run(&mut self) -> &mut OutputListBuilder<'a>
Runs all output items in the list, executing their output logic.
§Parameters
&mut self
: A mutable reference to the current instance ofOutputListBuilder
.
§Returns
&mut Self
: A mutable reference to the current instance, allowing for method chaining.
The method clones the current output list, clears the original list, and executes the output for each cloned item.
Sourcepub fn run_idx(&mut self, idx: usize) -> &mut OutputListBuilder<'a>
pub fn run_idx(&mut self, idx: usize) -> &mut OutputListBuilder<'a>
Runs the output item at the specified index.
§Parameters
&mut self
: A mutable reference to the current instance ofOutputListBuilder
.idx
: The index of the output item to run.
§Returns
&mut Self
: A mutable reference to the current instance, allowing for method chaining.
If the index is out of bounds, the list remains unchanged.
Trait Implementations§
Source§impl<'a> Clone for OutputListBuilder<'a>
impl<'a> Clone for OutputListBuilder<'a>
Source§fn clone(&self) -> OutputListBuilder<'a>
fn clone(&self) -> OutputListBuilder<'a>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl<'a> Freeze for OutputListBuilder<'a>
impl<'a> RefUnwindSafe for OutputListBuilder<'a>
impl<'a> Send for OutputListBuilder<'a>
impl<'a> Sync for OutputListBuilder<'a>
impl<'a> Unpin for OutputListBuilder<'a>
impl<'a> UnwindSafe for OutputListBuilder<'a>
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