Skip to main content

CompileOptions

Struct CompileOptions 

Source
pub struct CompileOptions {
Show 21 fields pub out_dir: Option<PathBuf>, pub target: BuildTarget, pub platform: Platform, pub roots: Roots, pub import_ext: ImportExt, pub contracts: bool, pub trace_requests: bool, pub inspect_agents: bool, pub tests: bool, pub sources: Option<HashMap<PathBuf, String>>, pub schema_registry: SchemaLock, pub contracts_lock: Option<String>, pub compatibility_flags: Vec<String>, pub workers_dev: Option<bool>, pub asset_files: Option<AssetFolder>, pub embed_files: Option<EmbedFolder>, pub fixture_files: Option<FixtureFolder>, pub migration_files: Option<AssetFolder>, pub snapshot_files: Option<BTreeMap<String, String>>, pub progress: Option<ProgressSink>, pub remote_tests: Option<RemoteTests>,
}
Expand description

Options for compile_project. Construct with CompileOptions::single or CompileOptions::split, then chain .target(…) / .platform(…) / .import_ext(…) to override the bundle/default-platform/.js defaults.

Fields§

§out_dir: Option<PathBuf>

#3477: the directory the build will be written to, when the caller knows it (bynk build and bynk compile), so a container’s build paths can be written from the Worker’s output directory back to the project. None uses the project’s [build] out.

§target: BuildTarget§platform: Platform§roots: Roots§import_ext: ImportExt

The import-specifier extension (slice 2). Js (default) for normal builds; Ts for the bynk test --inspect debug build.

§contracts: bool

v0.115 (testing track slice 3, DECISION J): the build profile for function contracts. true (dev/test) emits the call-site guard around a contracted fn; false (release/deploy) strips it entirely for zero runtime cost. bynk test and --inspect set it on; bynk compile leaves it off.

§trace_requests: bool

#3580 (the dev request-traces track): emit the per-request trace recording (__bynk_runtime/trace) into a Workers build, for bynk dev --trace-events. false for every other build, so a deploy build’s output is byte-identical. Dev-only by construction: only bynk dev sets it.

§inspect_agents: bool

#3581 (the dev agent-inspection track): emit the dev-only agent registry, the /_bynk/inspect routes and the instance recording into a Workers build, for bynk dev. false for every other build, so a deploy build’s output is byte-identical. Dev-only by construction: only bynk dev sets it.

§tests: bool

#1821 (ADR 0147 D3): whether suites are type-checked and emitted (the tests/ modules and tests/main.ts). On by default; bynk compile and the driver’s dev/deploy build turn it off, so a suite never reaches the deployable. bynk test leaves it on. Off strips suites after parsing: a file that does not parse still fails the build, since it cannot be told apart from production source.

§sources: Option<HashMap<PathBuf, String>>

#57 (testing track): when Some, every file roots would otherwise discover on disk is instead read from here — keyed the same way discovery::read_source’s overlay is (a canonicalised absolute path, falling back to the literal path when the file has no on-disk counterpart to canonicalise). Filesystem discovery is skipped entirely; roots still supplies src_root/tests_root and their prefixes, so a Roots::Split project can drive both trees in-memory.

#1077/#1081: bynk-driver’s project_options/try_project_options do set this now — the real CLI entry points walk and read every project file themselves and hand the result here, so bynk-emit itself no longer discovers or reads anything on disk for the CLI path. bynk/the LSP still don’t: bynk routes through bynk-driver, and the LSP (bynk_check::analysis::analyse_project since P4.2) never goes through CompileOptions at all — it has its own, separate discovery path (#1079). bynk-emit’s own tests also set this, to exercise the full project pipeline (cross-context uses, multi-file layouts, workers-mode emission, …) without an on-disk fixture tree.

§schema_registry: SchemaLock

Events track, slice 3c (#980): reconcile against bynk.schema.lock. Off by default — bynk compile’s directory branch and bynk’s deploy/dev build turn it on and write the reconciled lock back; check’s and test’s directory paths (#2078) turn it on read-only, so a non-additive change fails them too, and never write it. Every library/test caller (in-memory builds, bynk-tests/tests/e2e.rs’s in-place fixture compiles, bynk-emit’s own sources-driven tests, the LSP) leaves it off, so a compile never mutates a project tree it wasn’t asked to.

#1078: this carries the lock’s pre-read content, not just an on/off switch — bynk-emit reads and writes no disk for this file (the same move #1077/#1081 already made for .bynk source content). See SchemaLock’s own doc for the read side; the reconciled content comes back out on ProjectOutput::schema_lock for the caller to persist.

§contracts_lock: Option<String>

#2554: bynk.contracts.lock’s pre-read content: the older contracts each callee also accepts. None (every library, test and LSP caller, and a project without the file) accepts none, so a callee answers only the contract it has. bynk-driver’s try_project_options reads it, as it reads the manifest, so every CLI build honours it; a build only ever reads it, and the driver writes it.

§compatibility_flags: Vec<String>

#1890: the project’s extra Cloudflare compatibility flags, from bynk.toml’s [workers] compatibility_flags, in manifest order. A Workers build writes them into every wrangler.toml after bynk_emit::DEFAULT_COMPATIBILITY_FLAGS; a duplicate is dropped with a bynk.project.duplicate_compatibility_flag warning. Empty by default: bynk-driver’s project_options/try_project_options read the manifest and set it, as does bynk-tests/tests/e2e.rs for a fixture.

§workers_dev: Option<bool>

bynk.toml’s [workers] workers_dev: written into every wrangler.toml when set, left out when None.

§asset_files: Option<AssetFolder>

#1883, slice 1b: the project’s assets/ folder — its files, keyed by normalised project-relative path (assets/board.css), listed by the caller, and a reader for their bytes (assets::AssetFolder, usually AssetFolder::on_disk). The build reads only the files an asset declaration names, once each, through that reader, so bynk-emit never touches the disk and a large file nothing declares is never read. bynk-driver’s project_options/try_project_options and bynk-testkit’s compile_options_* set it.

None means no filesystem was consulted (compile_in_memory, the playground). A check then skips the existence check; a build treats it as an empty folder, so an asset there is bynk.asset.missing_file rather than a URL made up for a file nobody read.

§embed_files: Option<EmbedFolder>

#2387, slice 2: the project’s embeds/ folder, listed by the caller with a reader for the bytes of only the files an embed declaration names (assets::AssetFolder::embeds_on_disk), exactly as CompileOptions::asset_files does for assets/. None means no filesystem was consulted: a check then skips the existence check, and a build treats it as an empty folder, so an embed there is bynk.embed.missing_file rather than text made up for a file nobody read.

§fixture_files: Option<FixtureFolder>

#2841: the project’s fixtures/ folder, listed by the caller with a reader for the bytes of only the files a suite’s fixture declaration names (assets::AssetFolder::fixtures_on_disk), exactly as CompileOptions::embed_files does for embeds/. Fixtures are test input: nothing in a deployable reads them. None means no filesystem was consulted.

§migration_files: Option<AssetFolder>

P4b (#2608): the project’s migrations/ folder, listed by the caller (assets::AssetFolder::migrations_on_disk). Every file in a declared D1 database’s directory is read, checked, copied beside the Worker’s wrangler.toml and run on each test database. None means no filesystem was consulted.

§snapshot_files: Option<BTreeMap<String, String>>

#2842: the project’s snapshots/ folder, read by the caller (bynk_project::snapshots::read_snapshot_files): each file’s text by its project-relative path. A test module inlines the file for its own suite file, so the harness reads nothing at test time. None (and an empty map) means no snapshot is recorded, so every matches snapshot claim is missing.

§progress: Option<ProgressSink>

#3100: where compile_project reports each context as it compiles. None (the default, and every library, test and LSP caller) reports nothing, so a build behaves exactly as it did before.

§remote_tests: Option<RemoteTests>

#2138 (end-to-end testing track §3.5, §3.7): Some when bynk test --against runs the system suites against a real runtime. The build then emits only the system suites, routes their drivers to the target’s URLs (BYNK_TEST_TARGETS) instead of the in-process harness, and refuses (or, under --skip-unsupported, skips) a case that uses what a remote run can’t honour. None for every other build.

Implementations§

Source§

impl CompileOptions

Source

pub fn single(root: impl Into<PathBuf>) -> Self

Single-root project (src == tests), bundle target, default platform.

Source

pub fn split(project_root: impl Into<PathBuf>, paths: ProjectPaths) -> Self

v0.9.1 split layout (source and test units in separate subdirectories under project_root), bundle target, default platform. Use this from bynk test so its rooting matches bynk compile’s.

Source

pub fn out_dir(self, out: Option<PathBuf>) -> Self

#3477: the directory the build is written to (CompileOptions::out_dir).

Source

pub fn progress(self, sink: Option<ProgressSink>) -> Self

#3100: report each context as it compiles (CompileOptions::progress).

Source

pub fn remote_tests(self, remote: Option<RemoteTests>) -> Self

#2138: a remote test build (CompileOptions::remote_tests).

Source

pub fn target(self, target: BuildTarget) -> Self

Select the build target. Bundle (default) is the v0.6+ single-bundle layout; Workers (v0.8) emits per-context Cloudflare Workers.

Source

pub fn import_ext(self, ext: ImportExt) -> Self

Slice 2: select the import-specifier extension. Ts is the debug build for bynk test --inspect (run the .ts directly under Node strip-only).

Source

pub fn contracts(self, on: bool) -> Self

v0.115: enable the function-contract call-site guard (dev/test profile). bynk test and --inspect call this; the deploy build leaves it off so contract checks never reach production (DECISION J).

Source

pub fn trace_requests(self, on: bool) -> Self

#3580: record per-request traces in a Workers build (bynk dev --trace-events). Off by default, and never set by bynk compile or bynk deploy.

Source

pub fn inspect_agents(self, on: bool) -> Self

#3581: emit the dev-only agent inspection into a Workers build (bynk dev). Off by default, and never set by bynk compile or bynk deploy.

Source

pub fn tests(self, on: bool) -> Self

#1821 (ADR 0147 D3): whether to type-check and emit suites. A build that produces a deployable (bynk compile, bynk dev/deploy) turns it off; a suite is test-only.

Source

pub fn platform(self, platform: Platform) -> Self

v0.17: select the deploy Platform (selects the bynk surface binding). The MVP ships cloudflare only.

Source

pub fn sources(self, sources: HashMap<PathBuf, String>) -> Self

#57 (testing track): supply every file in-memory instead of walking roots on disk — keyed the same way discovery::read_source’s overlay is (see the sources field’s own doc).

Source

pub fn schema_registry(self, mode: SchemaLock) -> Self

Events track, slice 3c (#980): turn on bynk.schema.lock reconciliation for this build, with its pre-read content (or verified-absent None, for a fresh project). See SchemaLock and the field’s own doc for who calls this and why everyone else leaves it off.

Source

pub fn contracts_lock(self, content: Option<String>) -> Self

#2554: the contracts lock’s pre-read content. See the field’s own doc.

Source

pub fn compatibility_flags(self, flags: Vec<String>) -> Self

#1890: the project’s extra Cloudflare compatibility flags, from bynk.toml’s [workers] table. See the field’s own doc.

Source

pub fn workers_dev(self, workers_dev: Option<bool>) -> Self

The project’s [workers] workers_dev. See the field’s own doc.

Source

pub fn asset_files(self, folder: AssetFolder) -> Self

#1883, slice 1b: the listed assets/ folder. See the field’s own doc.

Source

pub fn embed_files(self, folder: EmbedFolder) -> Self

#2387, slice 2: the listed embeds/ folder. See the field’s own doc.

Source

pub fn fixture_files(self, folder: FixtureFolder) -> Self

#2841: the listed fixtures/ folder. See the field’s own doc.

Source

pub fn snapshot_files(self, files: BTreeMap<String, String>) -> Self

#2842: the project’s snapshots/ files. See the field’s own doc.

Source

pub fn migration_files(self, folder: AssetFolder) -> Self

P4b (#2608): the listed migrations/ folder. See the field’s own doc.

Trait Implementations§

Source§

impl Clone for CompileOptions

Source§

fn clone(&self) -> CompileOptions

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. 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
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<'a, T> FromIn<'a, T> for T

§

fn from_in(t: T, _: &'a Allocator) -> T

Converts to this type from the input type within the given allocator.
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<'a, T, U> IntoIn<'a, U> for T
where U: FromIn<'a, T>,

§

fn into_in(self, allocator: &'a Allocator) -> U

Converts this type into the (usually inferred) input type within the given allocator.
§

impl<D> OwoColorize for D

§

fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>
where C: Color,

Set the foreground color generically Read more
§

fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>
where C: Color,

Set the background color generically. Read more
§

fn black(&self) -> FgColorDisplay<'_, Black, Self>

Change the foreground color to black
§

fn on_black(&self) -> BgColorDisplay<'_, Black, Self>

Change the background color to black
§

fn red(&self) -> FgColorDisplay<'_, Red, Self>

Change the foreground color to red
§

fn on_red(&self) -> BgColorDisplay<'_, Red, Self>

Change the background color to red
§

fn green(&self) -> FgColorDisplay<'_, Green, Self>

Change the foreground color to green
§

fn on_green(&self) -> BgColorDisplay<'_, Green, Self>

Change the background color to green
§

fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>

Change the foreground color to yellow
§

fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>

Change the background color to yellow
§

fn blue(&self) -> FgColorDisplay<'_, Blue, Self>

Change the foreground color to blue
§

fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>

Change the background color to blue
§

fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>

Change the foreground color to magenta
§

fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>

Change the background color to magenta
§

fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>

Change the foreground color to purple
§

fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>

Change the background color to purple
§

fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>

Change the foreground color to cyan
§

fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>

Change the background color to cyan
§

fn white(&self) -> FgColorDisplay<'_, White, Self>

Change the foreground color to white
§

fn on_white(&self) -> BgColorDisplay<'_, White, Self>

Change the background color to white
§

fn default_color(&self) -> FgColorDisplay<'_, Default, Self>

Change the foreground color to the terminal default
§

fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>

Change the background color to the terminal default
§

fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>

Change the foreground color to bright black
§

fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>

Change the background color to bright black
§

fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>

Change the foreground color to bright red
§

fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>

Change the background color to bright red
§

fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>

Change the foreground color to bright green
§

fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>

Change the background color to bright green
§

fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>

Change the foreground color to bright yellow
§

fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>

Change the background color to bright yellow
§

fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>

Change the foreground color to bright blue
§

fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>

Change the background color to bright blue
§

fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>

Change the foreground color to bright magenta
§

fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>

Change the background color to bright magenta
§

fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>

Change the foreground color to bright purple
§

fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>

Change the background color to bright purple
§

fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>

Change the foreground color to bright cyan
§

fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>

Change the background color to bright cyan
§

fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>

Change the foreground color to bright white
§

fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>

Change the background color to bright white
§

fn bold(&self) -> BoldDisplay<'_, Self>

Make the text bold
§

fn dimmed(&self) -> DimDisplay<'_, Self>

Make the text dim
§

fn italic(&self) -> ItalicDisplay<'_, Self>

Make the text italicized
§

fn underline(&self) -> UnderlineDisplay<'_, Self>

Make the text underlined
Make the text blink
Make the text blink (but fast!)
§

fn reversed(&self) -> ReversedDisplay<'_, Self>

Swap the foreground and background colors
§

fn hidden(&self) -> HiddenDisplay<'_, Self>

Hide the text
§

fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>

Cross out the text
§

fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the foreground color at runtime. Only use if you do not know which color will be used at compile-time. If the color is constant, use either [OwoColorize::fg] or a color-specific method, such as [OwoColorize::green], Read more
§

fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the background color at runtime. Only use if you do not know what color to use at compile-time. If the color is constant, use either [OwoColorize::bg] or a color-specific method, such as [OwoColorize::on_yellow], Read more
§

fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the foreground color to a specific RGB value.
§

fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the background color to a specific RGB value.
§

fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>

Sets the foreground color to an RGB value.
§

fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>

Sets the background color to an RGB value.
§

fn style(&self, style: Style) -> Styled<&Self>

Apply a runtime-determined style
§

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.