Skip to main content

Instr

Enum Instr 

Source
#[repr(u8)]
pub enum Instr {
Show 117 variants Print(u16), Jmp(u16), JmpBack(u16), IsFalseJmp(u16, u16), IsTrueJmp(u16, u16), SupEqFloatJmp(u16, u16, u16), SupEqIntJmp(u16, u16, u16), SupFloatJmp(u16, u16, u16), SupIntJmp(u16, u16, u16), InfEqFloatJmp(u16, u16, u16), InfEqIntJmp(u16, u16, u16), InfFloatJmp(u16, u16, u16), InfIntJmp(u16, u16, u16), InfIntJmpBack(u16, u16, u16), StepIntJmpBack(u16, u16, u16), NotEqJmp(u16, u16, u16), EqJmp(u16, u16, u16), ObjNotEqJmp(u16, u16, u16), ObjEqJmp(u16, u16, u16), StrNotEqJmp(u16, u16, u16), StrEqJmp(u16, u16, u16), Mov(u16, u16), MovChain(u16, u16, u16), SetInt(u16, i32), SetBool(bool, u16), AddFloat(u16, u16, u16), AddInt(u16, u16, u16), AddIntImm(u16, i16, u16), AddArray(u16, u16, u16), AddStr(u16, u16, u16), MulFloat(u16, u16, u16), MulInt(u16, u16, u16), SubFloat(u16, u16, u16), SubInt(u16, u16, u16), DivFloat(u16, u16, u16), DivInt(u16, u16, u16), ModFloat(u16, u16, u16), ModInt(u16, u16, u16), PowFloat(u16, u16, u16), PowInt(u16, u16, u16), BitAndInt(u16, u16, u16), BitOrInt(u16, u16, u16), BitXorInt(u16, u16, u16), BitNotInt(u16, u16), ShlInt(u16, u16, u16), ShrInt(u16, u16, u16), IncInt(u16), DecInt(u16), IncIntTo(u16, u16), DecIntTo(u16, u16), Eq(u16, u16, u16), NotEq(u16, u16, u16), ObjEq(u16, u16, u16), ObjNotEq(u16, u16, u16), StrEq(u16, u16, u16), StrNotEq(u16, u16, u16), SupFloat(u16, u16, u16), SupInt(u16, u16, u16), SupEqFloat(u16, u16, u16), SupEqInt(u16, u16, u16), InfFloat(u16, u16, u16), InfInt(u16, u16, u16), InfEqFloat(u16, u16, u16), InfEqInt(u16, u16, u16), SupStr(u16, u16, u16), SupEqStr(u16, u16, u16), InfStr(u16, u16, u16), InfEqStr(u16, u16, u16), BoolAnd(u16, u16, u16), BoolOr(u16, u16, u16), NegBool(u16, u16), NegFloat(u16, u16), NegInt(u16, u16), CallFunc(u16, u16), CallFuncRecursive(u16, u16), VoidReturn, Return(u16), RecursiveReturn(u16), SaveFrame(u16, u16, u16), CallIndirect(u16), CallDynamicLibFunc(u16, u16), CallHostFunc(u16, u16), StoreFuncArg(u16), CallLibFunc(LibFunc, u16, u16), CallLibFuncVoid(LibFuncVoid, u16, u16), StartErrorCatch(u16, u16), StopErrorCatch, ThrowError(u16), ObjElemMov(u16, u16, u16), EmptyArray(u16), EmptyFnValue(u16), CloneArray(u16, u16, u16), CloneStruct(u16, u16), CloneEnum(u16, u16), SetElementObj(u16, u16, u16), SetElementString(u16, u16, u16), SetFieldStruct(u16, u16, u16), AddFieldFloat(u16, u16, u16), GetIndexArray(u16, u16, u16), GetIndexString(u16, u16, u16), GetFieldStruct(u16, u16, u16), GetSliceArray(u16, u16, u16), GetSliceString(u16, u16, u16), Push(u16, u16), Remove(u16, u16), MapGet(u16, u16, u16), MapInsert(u16, u16, u16), MapInsertReg(u16, u16, u16), MapRemove(u16, u16), CloneMap(u16, u16), NewCell(u16, u16), LoadCell(u16, u16), StoreCell(u16, u16), Halt(u16), CallNative(u16, u16), CallNativeRec(u16, u16), NativeExit,
}

Variants§

§

Print(u16)

§

Jmp(u16)

Jumps x instructions forwards

§

JmpBack(u16)

Jumps x instructions backwards

§

IsFalseJmp(u16, u16)

§

IsTrueJmp(u16, u16)

§

SupEqFloatJmp(u16, u16, u16)

§

SupEqIntJmp(u16, u16, u16)

§

SupFloatJmp(u16, u16, u16)

§

SupIntJmp(u16, u16, u16)

§

InfEqFloatJmp(u16, u16, u16)

§

InfEqIntJmp(u16, u16, u16)

§

InfFloatJmp(u16, u16, u16)

§

InfIntJmp(u16, u16, u16)

§

InfIntJmpBack(u16, u16, u16)

§

StepIntJmpBack(u16, u16, u16)

StepIntJmpBack(counter_reg, end_reg, size)
Adds 1 to the int in counter_reg, then jumps size instructions backwards while it is below the int in end_reg. The step at the bottom of every counted loop and every loop over a collection, which would otherwise be an IncInt and an InfIntJmpBack.

§

NotEqJmp(u16, u16, u16)

§

EqJmp(u16, u16, u16)

§

ObjNotEqJmp(u16, u16, u16)

§

ObjEqJmp(u16, u16, u16)

§

StrNotEqJmp(u16, u16, u16)

§

StrEqJmp(u16, u16, u16)

§

Mov(u16, u16)

§

MovChain(u16, u16, u16)

MovChain(dest, mid, src)
dest = mid, then mid = src: two moves where the second refills the register the first read, the way a = b; b = c; rotates values.

§

SetInt(u16, i32)

SetInt(dest_reg_id, val)
Writes val directly into dest_reg_id. The operand is narrower than an int, so a wider constant is moved out of its register instead, which keeps every instruction one word.

§

SetBool(bool, u16)

SetBool(dest_reg_id, val)
Writes val directly into dest_reg_id

§

AddFloat(u16, u16, u16)

§

AddInt(u16, u16, u16)

§

AddIntImm(u16, i16, u16)

AddIntImm(src_reg, imm, dest_reg)
dest = src + imm, for an int src. What adding or subtracting a constant that fits the operand compiles to.

§

AddArray(u16, u16, u16)

§

AddStr(u16, u16, u16)

§

MulFloat(u16, u16, u16)

§

MulInt(u16, u16, u16)

§

SubFloat(u16, u16, u16)

§

SubInt(u16, u16, u16)

§

DivFloat(u16, u16, u16)

§

DivInt(u16, u16, u16)

§

ModFloat(u16, u16, u16)

§

ModInt(u16, u16, u16)

§

PowFloat(u16, u16, u16)

§

PowInt(u16, u16, u16)

§

BitAndInt(u16, u16, u16)

§

BitOrInt(u16, u16, u16)

§

BitXorInt(u16, u16, u16)

§

BitNotInt(u16, u16)

BitNotInt(operand, dest)
dest = every bit of operand flipped

§

ShlInt(u16, u16, u16)

ShlInt(value, count, dest)
Raises shift_count_out_of_range for a count outside 0..64.

§

ShrInt(u16, u16, u16)

ShrInt(value, count, dest)
Arithmetic: int is signed, so the sign bit is what the vacated places are filled with. Raises shift_count_out_of_range for a count outside 0..64.

§

IncInt(u16)

Increments the integer in-place by 1

§

DecInt(u16)

Decrements the integer in-place by 1

§

IncIntTo(u16, u16)

IncIntTo(src, dst)
dst = src + 1

§

DecIntTo(u16, u16)

DecIntTo(src, dst)
dst = src - 1

§

Eq(u16, u16, u16)

§

NotEq(u16, u16, u16)

§

ObjEq(u16, u16, u16)

§

ObjNotEq(u16, u16, u16)

§

StrEq(u16, u16, u16)

§

StrNotEq(u16, u16, u16)

§

SupFloat(u16, u16, u16)

§

SupInt(u16, u16, u16)

§

SupEqFloat(u16, u16, u16)

§

SupEqInt(u16, u16, u16)

§

InfFloat(u16, u16, u16)

§

InfInt(u16, u16, u16)

§

InfEqFloat(u16, u16, u16)

§

InfEqInt(u16, u16, u16)

§

SupStr(u16, u16, u16)

SupStr(l_reg_id, r_reg_id, dest_reg_id)
Orders two strings by their bytes, the order sort puts a list of strings in. The four string comparisons are their own instructions rather than one carrying an ordering operand, because a fourth operand would take an instruction past a single word.

§

SupEqStr(u16, u16, u16)

SupEqStr(l_reg_id, r_reg_id, dest_reg_id)

§

InfStr(u16, u16, u16)

InfStr(l_reg_id, r_reg_id, dest_reg_id)

§

InfEqStr(u16, u16, u16)

InfEqStr(l_reg_id, r_reg_id, dest_reg_id)

§

BoolAnd(u16, u16, u16)

§

BoolOr(u16, u16, u16)

§

NegBool(u16, u16)

§

NegFloat(u16, u16)

§

NegInt(u16, u16)

§

CallFunc(u16, u16)

CallFunc(n,y)
Jumps to the nth instruction, and adds y as a slot to be set by the Return instruction
VoidReturn/Return will jump back to this location

§

CallFuncRecursive(u16, u16)

CallFuncRecursive(n, register_id)
Jumps to the nth instruction, register_id is only used during parsing.

§

VoidReturn

Jumps to the instruction right after the last CallFunc encountered by the interpreter

§

Return(u16)

Return(n)
Returns the data located in register n

§

RecursiveReturn(u16)

RecursiveReturn(n,function_id)
Returns the data located in register n, and restores the function’s register state

§

SaveFrame(u16, u16, u16)

SaveFrame(function_location, return_register, function_id)

§

CallIndirect(u16)

CallIndirect(callee_register_id)
Jumps to the instruction the function value in callee_register_id names in its first slot. The frame is pushed by the SaveFrame that precedes this instruction, which also carries the register the return lands in, so a call whose callee is only known at run time keeps the caller’s registers across it.

§

CallDynamicLibFunc(u16, u16)

CallDynamicLibFunc(fn_id, dest_register_id)

§

CallHostFunc(u16, u16)

CallHostFunc(host_fn_id, dest_register_id) Dispatches to a Rust closure registered on the embedding Engine, marshalling StoreFuncArg operands into the closure and its result back into dest_register_id.

§

StoreFuncArg(u16)

§

CallLibFunc(LibFunc, u16, u16)

CallLibFunc(function, src_register_id, dest_register_id)

§

CallLibFuncVoid(LibFuncVoid, u16, u16)

CallLibFuncVoid(function, src_register_1, src_register_2) For single-source ops, src register 2 is unused

§

StartErrorCatch(u16, u16)

StartErrorCatch(jump_size, error_register_id)

§

StopErrorCatch

§

ThrowError(u16)

ThrowError(error_register_id) Throws the error (a string) located in error_register_id

§

ObjElemMov(u16, u16, u16)

ArrayMov(new_elem_reg_id, array_id, idx)
Replaces the idx-th element in the array (with the id array_id) with the element located in new_elem_reg_id

§

EmptyArray(u16)

EmptyArray(array_reg_id) Allocates a fresh empty array and stores its address in array_reg_id

§

EmptyFnValue(u16)

EmptyFnValue(value_reg_id)
Allocates a fresh entry like EmptyArray and stores a function value naming it in value_reg_id. The pushes that follow fill it with where the body starts and the cells the function captured; the value is a function rather than the list it is built as, which is what makes it read as one wherever it becomes text.

§

CloneArray(u16, u16, u16)

CloneArray(src_reg, dest_reg, len) Allocates a fresh array with exact capacity len and clones the array in src_reg to dest_reg

§

CloneStruct(u16, u16)

§

CloneEnum(u16, u16)

CloneEnum(template_reg, dest_reg) Clones the enum value in template_reg into a fresh object-pool entry, preserving the enum type tag. Mirrors CloneStruct for enum values.

§

SetElementObj(u16, u16, u16)

SetElementArray(array_reg_id, new_elem_reg_id, idx)
Replaces the idx-th element in the array located in array_reg_id with the element located in new_elem_reg_id

§

SetElementString(u16, u16, u16)

SetElementString(string_reg_id, new_str_reg_id, idx)
Replaces the idx-th char in the string located in string_reg_id with the string located in new_str_reg_id

§

SetFieldStruct(u16, u16, u16)

SetFieldStruct(struct_reg_id, new_elem_reg_id, idx)

§

AddFieldFloat(u16, u16, u16)

AddFieldFloat(struct_reg_id, value_reg_id, field_idx)
Adds the float in value_reg_id to the float field field_idx of the struct, the whole of s.f += x.

§

GetIndexArray(u16, u16, u16)

GetIndexArray(array_reg_id, index_reg_id, output_reg_id)

§

GetIndexString(u16, u16, u16)

GetIndexString(str_reg_id, index_reg_id, output_reg_id)

§

GetFieldStruct(u16, u16, u16)

GetFieldStruct(struct_reg_id, index, output_reg_id)

§

GetSliceArray(u16, u16, u16)

GetSliceArray(array_reg_id, idx_start_reg_id, output_reg_id)
idx_end_reg_id is pulled from a StoreFuncArg

§

GetSliceString(u16, u16, u16)

GetSliceString(str_reg_id, idx_start_reg_id, output_reg_id)
idx_end_reg_id is pulled from a StoreFuncArg

§

Push(u16, u16)

Push(array_reg_id, elem_reg_id)

§

Remove(u16, u16)

Remove(array_reg_id, elem_index_reg_id)

§

MapGet(u16, u16, u16)

MapGet(map_pool_id, key_reg_id, dest_reg_id)

§

MapInsert(u16, u16, u16)

MapSet(map_pool_id, key_reg_id, val_reg_id)

§

MapInsertReg(u16, u16, u16)

MapSet(map_reg_id, key_reg_id, val_reg_id)

§

MapRemove(u16, u16)

MapRemove(map_reg_id, key_reg_id)

§

CloneMap(u16, u16)

§

NewCell(u16, u16)

NewCell(src_reg_id, dest_reg_id)
Allocates a one-slot cell holding what src_reg_id holds and puts the cell in dest_reg_id. A variable a closure captures lives in a cell, so the function that declared it and every closure that took it read and write one slot.

§

LoadCell(u16, u16)

LoadCell(cell_reg_id, dest_reg_id)
Reads the value out of the cell in cell_reg_id.

§

StoreCell(u16, u16)

StoreCell(cell_reg_id, src_reg_id)
Writes what src_reg_id holds into the cell in cell_reg_id.

§

Halt(u16)

Exits the program with the i32 code if it’s != 0

§

CallNative(u16, u16)

CallNative(function, dest_register_id)
A CallFunc whose callee runs as machine code: calls native function function of the loaded program and writes what it returns into dest_register_id.

§

CallNativeRec(u16, u16)

CallNativeRec(function, dest_register_id)
A CallFuncRecursive whose callee runs as machine code. The SaveFrame before it has pushed the frame the call returns through.

§

NativeExit

Where a call machine code makes into the interpreter returns to: the run that call started ends here.

Implementations§

Source§

impl Instr

Source

pub fn get_tgt_id(self) -> Option<u16>

Returns the ID of the register that will be modified by the given instruction

Source

pub fn tgt_id_mut(&mut self) -> Option<&mut u16>

The operand naming the register this instruction writes, to look at or to rewrite. See Self::get_tgt_id.

MovChain writes a second register, the one it refills, which this does not name; Self::for_each_write_reg names both. The compiler joins moves into it after every pass that rewrites registers.

Source

pub fn for_each_write_reg(self, f: impl FnMut(u16))

Calls f with each register this instruction writes: the one Self::get_tgt_id names, and for MovChain the register it refills as well.

Source

pub fn for_each_read_reg(self, f: impl FnMut(u16))

Calls f with each register this instruction reads.

Source

pub fn read_regs_mut(&mut self, f: impl FnMut(&mut u16))

Hands f each operand of this instruction that names a register it reads, to look at or to rewrite.

Trait Implementations§

Source§

impl Clone for Instr

Source§

fn clone(&self) -> Instr

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Instr

Source§

impl Debug for Instr

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Instr

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for Instr

Source§

impl PartialEq for Instr

Source§

fn eq(&self, other: &Instr) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Instr

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Instr

Auto Trait Implementations§

§

impl Freeze for Instr

§

impl RefUnwindSafe for Instr

§

impl Send for Instr

§

impl Sync for Instr

§

impl Unpin for Instr

§

impl UnsafeUnpin for Instr

§

impl UnwindSafe for Instr

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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.

§

impl<T> Paint for T
where T: ?Sized,

§

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();
§

fn primary(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Primary].

§Example
println!("{}", value.primary());
§

fn fixed(&self, color: u8) -> Painted<&T>

Returns self with the fg() set to [Color :: Fixed].

§Example
println!("{}", value.fixed(color));
§

fn rgb(&self, r: u8, g: u8, b: u8) -> Painted<&T>

Returns self with the fg() set to [Color :: Rgb].

§Example
println!("{}", value.rgb(r, g, b));
§

fn black(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Black].

§Example
println!("{}", value.black());
§

fn red(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Red].

§Example
println!("{}", value.red());
§

fn green(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Green].

§Example
println!("{}", value.green());
§

fn yellow(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Yellow].

§Example
println!("{}", value.yellow());
§

fn blue(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Blue].

§Example
println!("{}", value.blue());
§

fn magenta(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Magenta].

§Example
println!("{}", value.magenta());
§

fn cyan(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Cyan].

§Example
println!("{}", value.cyan());
§

fn white(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: White].

§Example
println!("{}", value.white());
§

fn bright_black(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightBlack].

§Example
println!("{}", value.bright_black());
§

fn bright_red(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightRed].

§Example
println!("{}", value.bright_red());
§

fn bright_green(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightGreen].

§Example
println!("{}", value.bright_green());
§

fn bright_yellow(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightYellow].

§Example
println!("{}", value.bright_yellow());
§

fn bright_blue(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightBlue].

§Example
println!("{}", value.bright_blue());
§

fn bright_magenta(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightMagenta].

§Example
println!("{}", value.bright_magenta());
§

fn bright_cyan(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightCyan].

§Example
println!("{}", value.bright_cyan());
§

fn bright_white(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightWhite].

§Example
println!("{}", value.bright_white());
§

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();
§

fn on_primary(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Primary].

§Example
println!("{}", value.on_primary());
§

fn on_fixed(&self, color: u8) -> Painted<&T>

Returns self with the bg() set to [Color :: Fixed].

§Example
println!("{}", value.on_fixed(color));
§

fn on_rgb(&self, r: u8, g: u8, b: u8) -> Painted<&T>

Returns self with the bg() set to [Color :: Rgb].

§Example
println!("{}", value.on_rgb(r, g, b));
§

fn on_black(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Black].

§Example
println!("{}", value.on_black());
§

fn on_red(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Red].

§Example
println!("{}", value.on_red());
§

fn on_green(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Green].

§Example
println!("{}", value.on_green());
§

fn on_yellow(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Yellow].

§Example
println!("{}", value.on_yellow());
§

fn on_blue(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Blue].

§Example
println!("{}", value.on_blue());
§

fn on_magenta(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Magenta].

§Example
println!("{}", value.on_magenta());
§

fn on_cyan(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Cyan].

§Example
println!("{}", value.on_cyan());
§

fn on_white(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: White].

§Example
println!("{}", value.on_white());
§

fn on_bright_black(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightBlack].

§Example
println!("{}", value.on_bright_black());
§

fn on_bright_red(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightRed].

§Example
println!("{}", value.on_bright_red());
§

fn on_bright_green(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightGreen].

§Example
println!("{}", value.on_bright_green());
§

fn on_bright_yellow(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightYellow].

§Example
println!("{}", value.on_bright_yellow());
§

fn on_bright_blue(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightBlue].

§Example
println!("{}", value.on_bright_blue());
§

fn on_bright_magenta(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightMagenta].

§Example
println!("{}", value.on_bright_magenta());
§

fn on_bright_cyan(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightCyan].

§Example
println!("{}", value.on_bright_cyan());
§

fn on_bright_white(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightWhite].

§Example
println!("{}", value.on_bright_white());
§

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();
§

fn bold(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Bold].

§Example
println!("{}", value.bold());
§

fn dim(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Dim].

§Example
println!("{}", value.dim());
§

fn italic(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Italic].

§Example
println!("{}", value.italic());
§

fn underline(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Underline].

§Example
println!("{}", value.underline());

Returns self with the attr() set to [Attribute :: Blink].

§Example
println!("{}", value.blink());

Returns self with the attr() set to [Attribute :: RapidBlink].

§Example
println!("{}", value.rapid_blink());
§

fn invert(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Invert].

§Example
println!("{}", value.invert());
§

fn conceal(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Conceal].

§Example
println!("{}", value.conceal());
§

fn strike(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Strike].

§Example
println!("{}", value.strike());
§

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();
§

fn mask(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Mask].

§Example
println!("{}", value.mask());
§

fn wrap(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Wrap].

§Example
println!("{}", value.wrap());
§

fn linger(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Linger].

§Example
println!("{}", value.linger());
§

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.

Returns self with the quirk() set to [Quirk :: Clear].

§Example
println!("{}", value.clear());
§

fn resetting(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Resetting].

§Example
println!("{}", value.resetting());
§

fn bright(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Bright].

§Example
println!("{}", value.bright());
§

fn on_bright(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: OnBright].

§Example
println!("{}", value.on_bright());
§

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);
§

fn new(self) -> Painted<Self>
where Self: Sized,

Create a new [Painted] with a default [Style]. Read more
§

fn paint<S>(&self, style: S) -> Painted<&Self>
where S: Into<Style>,

Apply a style wholesale to self. Any previous style is replaced. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.