Skip to main content

Client

Struct Client 

Source
pub struct Client<T> { /* private fields */ }
Expand description

Typed calls to the API.

Implementations§

Source§

impl<T: Transport> Client<T>

Source

pub const fn new(transport: T, poll: Duration, timeout: Duration) -> Self

A client over transport, waiting for decisions every poll for at most timeout.

Source

pub const fn transport(&self) -> &T

The transport.

Source

pub const fn poll(&self) -> Duration

How often it reads again while waiting (a decision, a growing log).

Source

pub async fn workers(&self) -> Result<WorkerList, ClientError>

GET /api/v1/workers.

§Errors

ClientError if the request fails or the answer doesn’t read.

Source

pub async fn triggers(&self) -> Result<TriggerList, ClientError>

GET /api/v1/triggers: every DAG’s trigger.

§Errors

ClientError if the request fails or the answer doesn’t read.

Source

pub async fn dag_trigger(&self, dag: &str) -> Result<TriggerView, ClientError>

GET /api/v1/dags/{dag}/trigger: a DAG’s trigger.

§Errors

ClientError if the request fails or the answer doesn’t read.

Source

pub async fn trigger_events( &self, dag: &str, limit: u32, ) -> Result<EventList, ClientError>

GET /api/v1/dags/{dag}/trigger/events: what it found, newest first.

§Errors

ClientError if the request fails or the answer doesn’t read.

Source

pub async fn post_event( &self, event: &PostEventRequest, ) -> Result<NamedEventView, ClientError>

POST /api/v1/events: posts an event (decision 354), sent under the current command key when with_command_key set one (so Client::submit can send it again safely).

§Errors

ClientError if the request fails or the answer doesn’t read.

Source

pub async fn named_events( &self, name: Option<&str>, limit: u32, ) -> Result<NamedEventList, ClientError>

GET /api/v1/events: the newest events posted, of name if given, at most limit.

§Errors

ClientError if the request fails or the answer doesn’t read.

Source

pub async fn restart_trigger( &self, dag: &str, ) -> Result<CommandView, ClientError>

POST /api/v1/dags/{dag}/trigger/restart: the command.

§Errors

ClientError if the request fails or the answer doesn’t read.

Source

pub async fn skip_trigger_run( &self, dag: &str, ) -> Result<CommandView, ClientError>

POST /api/v1/dags/{dag}/trigger/skip: the command.

§Errors

ClientError if the request fails or the answer doesn’t read.

Source

pub async fn switch_on_trigger( &self, dag: &str, ) -> Result<CommandView, ClientError>

POST /api/v1/dags/{dag}/trigger/switch-on: the command.

§Errors

ClientError if the request fails or the answer doesn’t read.

Source

pub async fn switched_off_sensors(&self) -> Result<SensorList, ClientError>

GET /api/v1/sensors/switched-off: the wait steps switched off.

§Errors

ClientError if the request fails or the answer doesn’t read.

Source

pub async fn switch_on_sensor( &self, dag: &str, sensor: &str, ) -> Result<CommandView, ClientError>

POST /api/v1/dags/{dag}/sensors/{sensor}/switch-on: the command.

§Errors

ClientError if the request fails or the answer doesn’t read.

Source

pub async fn run_resources( &self, run: &str, ) -> Result<ResourceList, ClientError>

GET /api/v1/runs/{run}/resources: a run’s resources.

§Errors

ClientError if the request fails or the answer doesn’t read.

Source

pub async fn deployment(&self) -> Result<DeploymentView, ClientError>

GET /api/v1/deployment: the deployment’s nodes and their configurations (masked).

§Errors

ClientError if the request fails or the answer doesn’t read.

Source

pub async fn samples( &self, range: &str, process: Option<&str>, ) -> Result<SampleSeriesList, ClientError>

GET /api/v1/metrics/samples: each process’s samples over range (1h, 24h, 7d, 30d), or one process’s.

§Errors

ClientError if the request fails or the answer doesn’t read.

Source

pub async fn task_flow(&self, range: &str) -> Result<TaskFlowList, ClientError>

GET /api/v1/metrics/tasks: the attempts over range in buckets: how many ended, by how, and the start latency of those started (decision 494).

§Errors

ClientError if the request fails or the answer doesn’t read.

Source

pub async fn memory_totals( &self, range: &str, ) -> Result<MemoryTotals, ClientError>

GET /api/v1/metrics/memory: every process’s memory together over range.

§Errors

ClientError if the request fails or the answer doesn’t read.

Source

pub async fn task_memory( &self, dag: &str, task: &str, ) -> Result<AttemptMemoryList, ClientError>

GET /api/v1/dags/{dag}/tasks/{task}/memory: the task’s last attempts’ peak memory.

§Errors

ClientError if the request fails or the answer doesn’t read.

Source

pub async fn dag_memory(&self, dag: &str) -> Result<DagMemoryList, ClientError>

GET /api/v1/dags/{dag}/memory: each task’s p95 peak memory against its limit.

§Errors

ClientError if the request fails or the answer doesn’t read.

Source

pub async fn import_errors(&self) -> Result<ImportErrorList, ClientError>

GET /api/v1/import-errors.

§Errors

ClientError if the request fails or the answer doesn’t read.

Source

pub async fn connections(&self) -> Result<ConnectionList, ClientError>

GET /api/v1/connections: each root’s connections and the tasks declaring them.

§Errors

ClientError if the request fails or the answer doesn’t read.

Source

pub async fn dags(&self) -> Result<DagList, ClientError>

GET /api/v1/dags.

§Errors

ClientError if the request fails or the answer doesn’t read.

Source

pub async fn dag(&self, dag: &str) -> Result<DagView, ClientError>

GET /api/v1/dags/{dag}.

§Errors

ClientError if the request fails (a DAG that doesn’t exist: the server’s 404) or the answer doesn’t read.

Source

pub async fn runs( &self, dag: &str, planned_for: Option<Timestamp>, ) -> Result<RunList, ClientError>

GET /api/v1/dags/{dag}/runs, optionally for one moment.

§Errors

ClientError if the request fails or the answer doesn’t read.

Source

pub async fn all_runs( &self, query: &AllRunsQuery, ) -> Result<RunList, ClientError>

GET /api/v1/runs?dag=...&state=...&before=...&before_run=...&limit=...: runs of every DAG (or one), newest triggered first.

§Errors

ClientError if the request fails or the answer doesn’t read.

Source

pub async fn run_dag(&self, run_id: &str) -> Result<Value, ClientError>

GET /api/v1/runs/{run}/dag: the DAG JSON of the version the run ran with.

§Errors

ClientError if the request fails or the answer doesn’t read.

Source

pub async fn run_commands( &self, run_id: &str, ) -> Result<CommandList, ClientError>

GET /api/v1/runs/{run}/commands.

§Errors

ClientError if the request fails or the answer doesn’t read.

Source

pub async fn output( &self, run_id: &str, task_id: &str, ) -> Result<OutputView, ClientError>

GET /api/v1/runs/{run}/tasks/{task}/output (an error with status 404 while it has none).

§Errors

ClientError if the request fails or the answer doesn’t read.

Source

pub async fn instance_output( &self, run_id: &str, task_id: &str, map_index: Option<u32>, ) -> Result<OutputView, ClientError>

As Self::output, of one instance of a mapped task (None: a mapped task’s whole list, decision 81).

§Errors

As Self::output.

Source

pub async fn events(&self) -> Result<EventReader, ClientError>

GET /api/v1/changes: what changed, as it happens (run, dag, workers and refresh events).

§Errors

ClientError if the stream can’t be opened.

Source

pub async fn command( &self, command_id: &str, ) -> Result<CommandView, ClientError>

GET /api/v1/commands/{command}: a command and the master’s decision.

§Errors

ClientError if the request fails or the answer doesn’t read.

Source

pub async fn run(&self, run_id: &str) -> Result<RunDetail, ClientError>

GET /api/v1/runs/{run}.

§Errors

ClientError if the request fails or the answer doesn’t read.

Source

pub async fn attempts( &self, run_id: &str, task_id: &str, ) -> Result<AttemptList, ClientError>

GET /api/v1/runs/{run}/tasks/{task}/attempts.

§Errors

ClientError if the request fails or the answer doesn’t read.

Source

pub async fn instance_attempts( &self, run_id: &str, task_id: &str, map_index: Option<u32>, ) -> Result<AttemptList, ClientError>

As Self::attempts, of one instance of a mapped task (decision 82).

§Errors

As Self::attempts.

Source

pub async fn log( &self, run_id: &str, task_id: &str, try_number: u32, from: u64, ) -> Result<LogChunk, ClientError>

GET /api/v1/runs/{run}/tasks/{task}/attempts/{try}/log?from=....

§Errors

ClientError if the request fails (the worker is gone, the log deleted) or the answer doesn’t read.

Source

pub async fn log_part( &self, run_id: &str, task_id: &str, try_number: u32, from: u64, limit: u64, ) -> Result<LogChunk, ClientError>

As Self::log, at most limit bytes (the API’s limits apply).

§Errors

As Self::log.

Source

pub async fn instance_log_part( &self, run_id: &str, __arg2: (&str, Option<u32>), try_number: u32, from: u64, limit: u64, ) -> Result<LogChunk, ClientError>

As Self::log_part, of one instance of a mapped task (decision 82).

§Errors

As Self::log.

Source

pub async fn set_paused( &self, dag: &str, paused: bool, cancel_runs: bool, ) -> Result<CommandView, ClientError>

POST /api/v1/dags/{dag}/pause or .../unpause: the command.

§Errors

ClientError if the request fails or the answer doesn’t read.

Source

pub async fn trigger( &self, dag: &str, planned_for: Option<Timestamp>, params: Option<&Map<String, Value>>, ) -> Result<CommandView, ClientError>

POST /api/v1/dags/{dag}/runs: the command; params, values for the run’s parameters over the DAG’s defaults.

§Errors

ClientError if the request fails or the answer doesn’t read.

Source

pub async fn trigger_with( &self, dag: &str, request: &TriggerRequest, ) -> Result<CommandView, ClientError>

POST /api/v1/dags/{dag}/runs: the command, for a run asked for in full.

§Errors

ClientError if the request fails or the answer doesn’t read.

Source

pub async fn backfill( &self, dag: &str, request: &BackfillRequest, ) -> Result<CommandView, ClientError>

POST /api/v1/dags/{dag}/backfills: the command (schedr runs backfill).

§Errors

ClientError if the request fails or the answer doesn’t read.

Source

pub async fn dag_backfills( &self, dag: &str, ) -> Result<BackfillList, ClientError>

GET /api/v1/dags/{dag}/backfills: its newest backfills.

§Errors

ClientError if the request fails or the answer doesn’t read.

Source

pub async fn get_backfill( &self, backfill_id: &str, ) -> Result<BackfillView, ClientError>

GET /api/v1/backfills/{backfill}.

§Errors

ClientError if the request fails or the answer doesn’t read.

Source

pub async fn cancel_backfill( &self, backfill_id: &str, ) -> Result<CommandView, ClientError>

POST /api/v1/backfills/{backfill}/cancel: the command (schedr runs cancel --backfill).

§Errors

ClientError if the request fails or the answer doesn’t read.

Source

pub async fn check_connections( &self, request: &CheckConnectionsRequest, ) -> Result<CommandView, ClientError>

POST /api/v1/connections/check: the command (schedr connections check).

§Errors

ClientError if the request fails or the answer doesn’t read.

Source

pub async fn test_connection( &self, name: &str, request: &TestConnectionRequest, ) -> Result<CommandView, ClientError>

POST /api/v1/connections/{name}/test: the command (schedr connections test).

§Errors

ClientError if the request fails or the answer doesn’t read.

Source

pub async fn wait_connections( &self, command: CommandView, timeout: Duration, ) -> Result<ConnectionsResult, ClientError>

Reads an applied connections command back until every job has its answer (or was lost), for at most timeout: its result.

§Errors

ClientError::Timeout if a worker hasn’t answered by then, a result that doesn’t read (ClientError::Unexpected), or a request failure.

Source

pub async fn cancel(&self, run_id: &str) -> Result<CommandView, ClientError>

POST /api/v1/runs/{run}/cancel: the command.

§Errors

ClientError if the request fails or the answer doesn’t read.

Source

pub async fn task_action( &self, run_id: &str, __arg2: (&str, Option<u32>), action: TaskAction, ) -> Result<CommandView, ClientError>

POST /api/v1/runs/{run}/tasks/{task}/{action} (cancel or retry): the command.

§Errors

ClientError if the request fails or the answer doesn’t read.

Source

pub async fn worker_action( &self, worker_id: &str, action: WorkerAction, ) -> Result<CommandView, ClientError>

POST /api/v1/workers/{worker}/{action} (drain or resume): the command.

§Errors

ClientError if the request fails or the answer doesn’t read.

Source

pub async fn send_command<F>( &self, request: impl Fn() -> F, ) -> Result<CommandView, ClientError>
where F: Future<Output = Result<CommandView, ClientError>>,

Self::submit under a new key: one command, stored once however often it is sent (boxed: its future stays small in the caller’s). For one-shot callers (the CLI), whose key is gone once they return.

§Errors

As Self::submit, but ClientError::Unanswered when no answer came: the command may have arrived.

Source

pub async fn submit<R, F>( &self, key: String, request: impl Fn() -> F, ) -> Result<R, ClientError>
where F: Future<Output = Result<R, ClientError>>,

Sends a command with request, stored once (B140): under key (the client’s Idempotency-Key; new_command_key for a new one), and sent again with the same key, at most COMMAND_TRIES times in all, while no answer comes or the server fails (it may have stored it): the webserver gives the command stored the first time.

§Errors

The last try’s ClientError, or the first that isn’t worth another try (the server refused the command).

Source

pub async fn wait( &self, command: CommandView, ) -> Result<CommandView, ClientError>

Reads command back until the master decides it.

§Errors

ClientError::Rejected with the master’s reason, ClientError::Timeout if it stays pending, or a request failure.

Trait Implementations§

Source§

impl<T: Clone> Clone for Client<T>

Source§

fn clone(&self) -> Client<T>

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<T: Debug> Debug for Client<T>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Client<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Client<T>
where T: RefUnwindSafe,

§

impl<T> Send for Client<T>
where T: Send,

§

impl<T> Sync for Client<T>
where T: Sync,

§

impl<T> Unpin for Client<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for Client<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for Client<T>
where T: UnwindSafe,

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

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

impl<T> Same for T

Source§

type Output = T

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

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