Skip to main content

Dispatcher

Struct Dispatcher 

Source
pub struct Dispatcher { /* private fields */ }
Expand description

Tasks given to workers and their reports handled.

Implementations§

Source§

impl Dispatcher

Source

pub fn new(db: Database, cancel_grace: Duration) -> Self

A dispatcher over db with no workers.

Source

pub const fn with_sensor_max_wait(self, max_wait: Duration) -> Self

How long a wait step without a max_wait waits.

Source

pub const fn with_switch_off_after(self, times: u32) -> Self

After how many host kills in a row a wait step is switched off (0: never).

Source

pub fn set_scheduler(&mut self, scheduler: Scheduler)

Creates the runs TriggerDagOperators start with scheduler (the core’s, sharing its wakes), not one of its own.

Source

pub fn set_metrics(&mut self, metrics: MasterMetrics)

Counts assignments, rejections, ended attempts, waiting tasks and finished runs in metrics.

Source

pub fn set_wakes(&mut self, wakes: Wakes)

Wakes the DAGs of the runs it finishes through wakes.

Source

pub fn memory(&self) -> Memory

A copy of what a worker’s message changes in memory (worker slots, rejections, code missing, the cancels queued for the next step), to Self::restore if the message’s transaction rolls back: memory then shows only what is stored (code review of 2.10b; metrics already counted stay).

Source

pub fn recount(&mut self)

Drops the concurrency limits’ counts, read again from the database at the next round with tasks ready: after a commit whose answer was lost (it may have stored what the counts were changed for, or not), where neither the counts before nor after can be trusted. Put back as they were, an expiry stored would leave its attempt counted for good, its DAG’s limit holding tasks back until a restart (Codex’s review of M4.4).

Source

pub fn undo(&mut self, memory: Memory, error: &DispatchError)

Puts back a copy taken by Self::memory after its transaction failed; for a commit whose answer was lost the counts are read again instead (Self::recount).

Source

pub fn take_witnesses(&mut self) -> Vec<(String, Witness)>

The attempts started or ended since the last call (see witnesses), and none from now.

Source

pub fn restore(&mut self, memory: Memory)

Puts back a copy taken by Self::memory.

Source

pub fn with_arrivals(self, arrivals: Arrivals) -> Self

The dispatcher reading which attempts’ Started arrived from arrivals (the core’s, which the streams’ readers fill), so it doesn’t take them back as never started.

Source

pub fn with_event_lookback(self, lookback: Duration) -> Self

The dispatcher reading back lookback behind an event sensor’s cursor (B185).

Source

pub fn with_lease(self, lease: Duration) -> Self

The dispatcher holding a replaced incarnation’s attempts for lease, the worker lease (decision 443): the old process may run them that long.

Source

pub fn with_cleanup_move_wait(self, wait: Duration) -> Self

The dispatcher waiting wait before a lost worker’s cleanup moves.

Source

pub fn with_set_aside(self, set_aside: Duration, read_back: ReadBack) -> Self

The dispatcher leaving a task whose assignment fails on its own out for set_aside, and reading a commit cut off back as read_back says (set_aside, read_back_window, read_back_interval).

Source

pub const fn read_back(&self) -> ReadBack

How a commit cut off is read back (see ReadBack).

Source

pub const fn with_handed_call_min(self, least: Duration) -> Self

The dispatcher giving an @sensor(wait_for=...)’s call at least least once it is handed its run (see DEFAULT_HANDED_CALL_MIN).

Source

pub const fn with_max_message_size(self, bytes: usize) -> Self

The largest message a worker takes ([grpc] max_message_size).

Source

pub fn set_notifications(&mut self, notifications: Arc<Notifications>)

What finished runs and tasks notify ([notifications]).

Source

pub const fn set_max_instances(&mut self, max_instances: usize)

The most instances a mapped task may have ([mapping] max_instances).

Source

pub const fn set_rounds(&mut self, rounds: RoundLimits)

How much a round does at most (decision 493), its execution’s part too.

Source

pub fn with_code_retry_delay(self, delay: Duration) -> Self

When a task whose code wasn’t on its worker yet is tried again (see CODE_RETRY_DELAY).

Source

pub fn with_code_wait(self, code_wait: Duration) -> Self

The dispatcher with another code wait (see DEFAULT_CODE_WAIT).

Source

pub const fn workers(&self) -> &Workers

The registered workers.

Source

pub const fn active(&self) -> &Active

The open attempts counted for the concurrency limits.

Source

pub async fn register( &mut self, worker_id: &str, incarnation: &str, queues: &[String], slots: u32, now: Timestamp, ) -> Result<(), DispatchError>

A worker registered. A new worker or a restarted one gives unschedulable tasks another chance.

§Errors

DispatchError::Db if the database fails.

Source

pub fn set_current_code( &mut self, root: &str, accepted: &BTreeSet<String>, version: Option<SchedrVersion>, )

A root’s accepted content hashes and its current parse’s schedr version (see crate::discovery): its tasks go only to workers that have the root at one of those hashes and are of at least that version.

Source

pub fn set_connections( &mut self, registries: &BTreeMap<String, Arc<Registry>>, parsed: &BTreeMap<String, String>, )

Each root’s connections (decision 174): a task’s assignment carries those it declares. parsed is the content hash of each root’s current parse (its registry’s).

Source

pub fn worker_disconnected(&mut self, worker_id: &str)

A worker’s stream ended: no task, cleanup nor connections job goes to it until it registers again.

Source

pub fn worker_away(&mut self, worker_id: &str)

A worker a restarted master read back, not registered with it yet (see away).

Source

pub fn connection_roots(&self) -> Vec<String>

The roots having connections, by name.

Source

pub fn registry(&self, root: &str) -> Option<&Arc<Registry>>

A root’s connections, if it has any.

Source

pub fn connection_worker( &self, root: &str, wanted: Option<&str>, ) -> Result<(String, String), String>

The worker a connections job of root goes to (decision 193), with the hash it has the root at: wanted, else a connected, active worker having the root’s current code, the one running the fewest attempts. Why none can, otherwise. The current code is the current parse’s exactly (not newer code whose parse is on its way): its connections are the ones the job carries.

§Errors

Why no worker can take it, for the command’s rejection.

Source

pub fn set_worker_version( &mut self, worker_id: &str, version: Option<SchedrVersion>, )

A worker’s schedr version: it gets only tasks of parses no newer.

Source

pub fn report_root(&mut self, worker_id: &str, root: &str, hash: &str)

A worker reported a root’s content hash.

Source

pub fn withdraw_root(&mut self, worker_id: &str, root: &str)

A worker withdrew a root (decision 303): its tasks no longer go there.

Source

pub async fn adopt( &mut self, worker_id: &str, attempt_id: &str, now: Timestamp, ) -> Result<(), DispatchError>

A reconnecting worker still runs attempt_id (or holds its result): it keeps its slot, and the attempt counts as started, so it isn’t taken back for want of a Started lost with the old stream (B50).

§Errors

DispatchError::Db if the database fails.

Source

pub async fn attempt_inputs( &self, attempt_id: &str, ) -> Result<Option<Vec<u8>>, DispatchError>

The inputs of an open attempt as JSON (see attempt_inputs).

§Errors

DispatchError::Db if the database fails.

Source

pub fn draining(&mut self, worker_id: &str)

A worker is draining: it gets no new tasks.

Source

pub fn drain(&mut self, worker_id: &str) -> Vec<Outgoing>

A worker is drained for maintenance: it gets no new tasks, and its pokes move at once: the messages that say so.

Source

pub fn set_drained(&mut self, worker_id: &str)

A worker is drained, as it was before it registered: its pokes are moved once they are known again (Self::drain).

Source

pub fn is_poke(&self, worker_id: &str, attempt_id: &str) -> bool

Whether an attempt on a worker is a poke, which a drain moves at once.

Source

pub fn set_watcher_slots(&mut self, worker_id: &str, slots: u32)

A worker’s watcher slots.

Source

pub async fn resume( &mut self, worker_id: &str, now: Timestamp, ) -> Result<(), DispatchError>

A drained worker is resumed: like a new worker, it gives unschedulable tasks another chance.

§Errors

DispatchError::Db if the database fails.

Source

pub async fn step( &mut self, now: Timestamp, ) -> Result<Vec<Outgoing>, DispatchError>

One step of the loop: new runs get their tasks, retries whose delay passed are queued, assignments with no Started are taken back, and ready tasks are assigned.

§Errors

DispatchError if the database fails.

Source

pub async fn step_into( &mut self, now: Timestamp, outgoing: &mut Vec<Outgoing>, ) -> Result<(), DispatchError>

As Self::step, into outgoing: the assignments made before a failure are there still (each stored before its message is built, B7).

§Errors

DispatchError if the database fails.

Source

pub async fn prepare( &mut self, now: Timestamp, outgoing: &mut Vec<Outgoing>, ) -> Result<(), DispatchError>

A round’s first part of the dispatcher’s: runs prepared, due retries queued.

§Errors

DispatchError if the database fails.

Source

pub async fn expire_round( &mut self, now: Timestamp, ) -> Result<(), DispatchError>

A round’s part: assignments past their worker’s echo expired, replaced incarnations’ attempts ended.

§Errors

DispatchError if the database fails.

Source

pub async fn assign_round( &mut self, now: Timestamp, outgoing: &mut Vec<Outgoing>, ) -> Result<(), DispatchError>

A round’s assignments (Self::assign_into), the mapped lists read afresh: a worker’s turn may have run since the round’s last part (decision 469).

§Errors

DispatchError if the database fails.

Source

pub async fn assign( &mut self, now: Timestamp, ) -> Result<Vec<Outgoing>, DispatchError>

Assigns ready tasks to workers with free slots.

§Errors

DispatchError if the database fails.

Source

pub async fn assign_into( &mut self, now: Timestamp, outgoing: &mut Vec<Outgoing>, ) -> Result<(), DispatchError>

As Self::assign, into outgoing: all of the step’s assignments, or, after a failure, none (nothing of them stored either).

§Errors

DispatchError if the database fails.

Source

pub async fn started( &mut self, worker_id: &str, started: &Started, now: Timestamp, ) -> Result<Option<Outgoing>, DispatchError>

A worker reported Started. Returns a CancelAttempt if the attempt was taken back, ended or belongs to another worker.

§Errors

DispatchError::Db if the database fails.

Source

pub async fn started_group( &mut self, worker_id: &str, group: &[Started], now: Timestamp, ) -> Result<Vec<Outgoing>, DispatchError>

A turn’s Starteds together (M5.1d), as Self::started handles each: the attempts read in one query, their starts recorded in a statement for each start method. One that isn’t this worker’s, or is no longer running, is answered with a cancel.

§Errors

DispatchError::Db if the database fails: the caller’s transaction rolls back, and the messages are handled one by one.

Source

pub fn set_steady(&mut self, steady: Steady)

Times this dispatcher on steady (see crate::clock).

Source

pub fn set_wall(&mut self, wall: fn() -> Timestamp)

Reads the wall clock from wall where it is compared with master time (M5.1m).

Source

pub async fn rejected( &mut self, worker_id: &str, rejected: &Rejected, now: Timestamp, ) -> Result<(), DispatchError>

A worker rejected an assignment.

§Errors

DispatchError::BadMessage for an unknown reason, or DispatchError::Db.

Source

pub async fn task_ended( &mut self, worker_id: &str, result: &Finished, now: Timestamp, ) -> Result<(), DispatchError>

A worker’s task ended and its cleanup starts: the instance is cleaning_up, its attempt open until Finished, and the task’s result kept, for a worker lost meanwhile (decision 229). Only from the worker it was assigned to (B46).

§Errors

DispatchError if the database fails.

Source

pub async fn finished( &mut self, worker_id: &str, finished: &Finished, now: Timestamp, ) -> Result<Outgoing, DispatchError>

A worker reported Finished: stored once (only from the worker the attempt was assigned to, B46), and always acknowledged.

§Errors

DispatchError::BadMessage for an unknown status, or a database failure.

Source

pub async fn finished_group( &mut self, worker_id: &str, group: &[Finished], now: Timestamp, ) -> Result<Vec<Outgoing>, DispatchError>

A turn’s Finisheds together (M4B.4, B184): the attempts read in one query, the common case (the worker’s own attempt, not moved, its first result) ended in one statement, its outputs in another, each run read and moved forward once. Any other (a moved cleanup’s, a rest, another worker’s, code gone missing, a repeat) goes through Self::finished alone, first. Each is acknowledged.

§Errors

DispatchError if a message is malformed or the database fails: the caller’s transaction rolls back, and the messages are handled one by one.

Source

pub async fn expire(&mut self, now: Timestamp) -> Result<usize, DispatchError>

Takes back assignments the worker’s echo shows it never started (B240): a message from it named the assignment’s number as handled, with no Started (or Finished) before. They end assignment_expired and their tasks run again without using a retry; a moved cleanup never started goes on waiting for another worker. One not known unstarted stays: its worker hasn’t handled it yet (it does, in order), or its lease runs out (Self::worker_lost decides), or it registers again (its journal decides, Self::unreported_unstarted). Returns how many attempts ended.

§Errors

DispatchError if the database fails.

Source

pub async fn incarnation_replaced( &mut self, worker_id: &str, reported: &BTreeSet<&str>, now: Timestamp, ) -> Result<usize, DispatchError>

A worker’s agent restarted (a new incarnation), before its stream replaces the old one’s: the attempts the old process may run and the new one doesn’t report are marked, and end lost with a WorkerRestarted error summary once the old incarnation’s lease is over in master time (decision 443, B230: the old process may still run them meanwhile; see Self::end_replaced), each using a retry, as for a lost worker (the crash may have been the task’s own; see archive/PROJECT.md, Worker lifecycle). Those are the started ones, and the unstarted ones the old stream’s echo doesn’t show it never started (B240: its Started may have been lost with its stream). Those it shows never started are taken back now, without using a retry; a moved cleanup among them waits for another worker. Returns how many were marked.

§Errors

DispatchError if the database fails.

Source

pub async fn unreported_unstarted( &mut self, worker_id: &str, reported: &BTreeSet<&str>, now: Timestamp, ) -> Result<usize, DispatchError>

The same process registered again (a stream broken, the worker running on): its journal holds every assignment it accepted, so one not started and not in it never started there, and is taken back now (B240; what its old stream still carries, it drops). Returns how many.

§Errors

DispatchError if the database fails.

Source

pub async fn reported( &mut self, worker_id: &str, attempt_ids: &[String], ) -> Result<(), DispatchError>

The attempts worker_id’s journal reports at its registration: alive there, none of its own is held for a replaced incarnation any more (Grok’s review of decision 443: one told to continue was still ended when the hold ran out). Another worker’s, which its journal can’t keep, stays held.

§Errors

DispatchError if the database fails.

Source

pub async fn end_replaced( &mut self, now: Timestamp, ) -> Result<usize, DispatchError>

Ends lost the attempts a replaced incarnation left behind whose lease is over in master time (decision 443), each whole or not at all; a kept result the database refuses is dropped, as for a lost worker. Returns how many ended.

§Errors

DispatchError if the database fails.

Source

pub async fn worker_lost( &mut self, worker_id: &str, results: KeptResults, now: Timestamp, ) -> Result<(), DispatchError>

A worker is lost or gone: its started attempts end lost with a WorkerLost error summary (each uses a retry), the ones it never started assignment_expired with a WorkerLeft one (queued again, no retry), and it is forgotten.

§Errors

DispatchError if the database fails.

Source

pub async fn handles_added( &mut self, worker_id: &str, added: &HandlesAdded, ) -> Result<(), DispatchError>

Handles an attempt registered, kept for a cleanup on another worker (decision 242). Only from the worker it is assigned to (B46), while it is open, and up to what an attempt may hold (decision 228); a handle that doesn’t read is left out.

§Errors

DispatchError if the database fails.

Source

pub async fn cancel_task( &mut self, run_id: &str, __arg2: (&TaskId, Option<i32>), now: Timestamp, ) -> Result<(TaskCancel, Vec<Outgoing>), DispatchError>

Cancels one task of a run (see Execution::cancel_task); a CancelAttempt for its attempt if it runs.

§Errors

DispatchError for an unknown run or task, or a database failure.

Source

pub async fn retry_task( &mut self, run_id: &str, __arg2: (&TaskId, Option<i32>), now: Timestamp, ) -> Result<TaskRetry, DispatchError>

Queues an unschedulable task of an unfinished run again (see Execution::retry_task), forgetting which workers rejected it (schedr tasks retry).

§Errors

DispatchError for an unknown run or task, or a database failure.

Source

pub async fn cancel_run( &mut self, run_id: &str, now: Timestamp, ) -> Result<Vec<Outgoing>, DispatchError>

Cancels a run; returns a CancelAttempt for each of its running attempts.

§Errors

DispatchError for an unknown run or a database failure.

Source

pub fn place_trigger( &mut self, active: &ActiveDag, instance: &str, (after, failures): (Option<String>, u32), now: Timestamp, ) -> Option<(Outgoing, String)>

The worker to run a DAG’s trigger: as a wait step’s, on a watcher slot, which it takes. Gives the assignment and the code it was picked for; None when no worker has a free one, or the root’s current code isn’t known yet (a parse on its way after a restart).

Source

pub fn worker(&self, id: &str) -> Option<&Worker>

A worker: what the trigger pass asks of the one running a trigger.

Source

pub fn trigger_kept(&mut self, worker: &str, instance: &str, now: Timestamp)

A trigger keeps its watcher slot on the worker that came back with it.

Source

pub fn trigger_released(&mut self, instance: &str)

A trigger gave up its watcher slot: the trigger loop looks (another may start there).

Source

pub fn trigger_wake(&self) -> Arc<Notify> ⓘ

What the trigger loop waits on besides writes: told when a trigger’s state changes in memory only.

Trait Implementations§

Source§

impl Debug for Dispatcher

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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 more
§

impl<T> IntoRequest<T> for T

§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<L> LayerExt<L> for L

§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in [Layered].
§

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
§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more