Struct CompileOptions
pub struct CompileOptions {
pub target: BuildTarget,
pub platform: Platform,
pub roots: Roots,
pub import_ext: ImportExt,
pub contracts: bool,
pub tests: bool,
pub sources: Option<HashMap<PathBuf, String>>,
pub schema_registry: SchemaLock,
pub compatibility_flags: Vec<String>,
pub asset_files: Option<AssetFolder>,
pub embed_files: Option<AssetFolder>,
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§
§target: BuildTarget§platform: Platform§roots: Roots§import_ext: ImportExtThe import-specifier extension (slice 2). Js (default) for normal builds;
Ts for the bynkc test --inspect debug build.
contracts: boolv0.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.
bynkc test and --inspect set it on; bynkc compile leaves it off.
tests: bool#1821 (ADR 0147 D3): whether suites are type-checked and emitted (the
tests/ modules and tests/main.ts). On by default; bynkc compile
and the driver’s dev/deploy build turn it off, so a suite never reaches
the deployable. bynkc 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. bynkc/the LSP still don’t: bynkc 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: SchemaLockEvents track, slice 3c (#980): reconcile against bynk.schema.lock.
Off by default — bynkc 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, bynkc/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.
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
[crate::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 bynkc/tests/e2e.rs for a fixture.
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<AssetFolder>#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.
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§
§impl CompileOptions
impl CompileOptions
pub fn single(root: impl Into<PathBuf>) -> CompileOptions
pub fn single(root: impl Into<PathBuf>) -> CompileOptions
Single-root project (src == tests), bundle target, default platform.
pub fn split(
project_root: impl Into<PathBuf>,
paths: ProjectPaths,
) -> CompileOptions
pub fn split( project_root: impl Into<PathBuf>, paths: ProjectPaths, ) -> CompileOptions
v0.9.1 split layout (source and test units in separate subdirectories
under project_root), bundle target, default platform. Use this from
bynkc test so its rooting matches bynkc compile’s.
pub fn remote_tests(self, remote: Option<RemoteTests>) -> CompileOptions
pub fn remote_tests(self, remote: Option<RemoteTests>) -> CompileOptions
#2138: a remote test build (CompileOptions::remote_tests).
pub fn target(self, target: BuildTarget) -> CompileOptions
pub fn target(self, target: BuildTarget) -> CompileOptions
Select the build target. Bundle (default) is the v0.6+ single-bundle
layout; Workers (v0.8) emits per-context Cloudflare Workers.
pub fn import_ext(self, ext: ImportExt) -> CompileOptions
pub fn import_ext(self, ext: ImportExt) -> CompileOptions
Slice 2: select the import-specifier extension. Ts is the debug build
for bynkc test --inspect (run the .ts directly under Node strip-only).
pub fn contracts(self, on: bool) -> CompileOptions
pub fn contracts(self, on: bool) -> CompileOptions
v0.115: enable the function-contract call-site guard (dev/test profile).
bynkc test and --inspect call this; the deploy build leaves it off so
contract checks never reach production (DECISION J).
pub fn tests(self, on: bool) -> CompileOptions
pub fn tests(self, on: bool) -> CompileOptions
#1821 (ADR 0147 D3): whether to type-check and emit suites. A build
that produces a deployable (bynkc compile, bynk dev/deploy) turns
it off; a suite is test-only.
pub fn platform(self, platform: Platform) -> CompileOptions
pub fn platform(self, platform: Platform) -> CompileOptions
v0.17: select the deploy Platform (selects the bynk surface
binding). The MVP ships cloudflare only.
pub fn sources(self, sources: HashMap<PathBuf, String>) -> CompileOptions
pub fn sources(self, sources: HashMap<PathBuf, String>) -> CompileOptions
#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).
pub fn schema_registry(self, mode: SchemaLock) -> CompileOptions
pub fn schema_registry(self, mode: SchemaLock) -> CompileOptions
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.
pub fn compatibility_flags(self, flags: Vec<String>) -> CompileOptions
pub fn compatibility_flags(self, flags: Vec<String>) -> CompileOptions
#1890: the project’s extra Cloudflare compatibility flags, from
bynk.toml’s [workers] table. See the field’s own doc.
pub fn asset_files(self, folder: AssetFolder) -> CompileOptions
pub fn asset_files(self, folder: AssetFolder) -> CompileOptions
#1883, slice 1b: the listed assets/ folder. See the field’s own doc.
pub fn embed_files(self, folder: AssetFolder) -> CompileOptions
pub fn embed_files(self, folder: AssetFolder) -> CompileOptions
#2387, slice 2: the listed embeds/ folder. See the field’s own doc.
Trait Implementations§
§impl Clone for CompileOptions
impl Clone for CompileOptions
§fn clone(&self) -> CompileOptions
fn clone(&self) -> CompileOptions
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for CompileOptions
impl !RefUnwindSafe for CompileOptions
impl Send for CompileOptions
impl Sync for CompileOptions
impl Unpin for CompileOptions
impl UnsafeUnpin for CompileOptions
impl !UnwindSafe for CompileOptions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<'a, T> FromIn<'a, T> for T
impl<'a, T> FromIn<'a, T> for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 Twhere
U: FromIn<'a, T>,
impl<'a, T, U> IntoIn<'a, U> for Twhere
U: FromIn<'a, T>,
§impl<D> OwoColorize for D
impl<D> OwoColorize for D
§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
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,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
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>
fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>
§fn bg_rgb<const R: u8, const G: u8, const B: u8>(
&self,
) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>
fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>
§fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>
fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>
§fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>
fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>
§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
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 bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
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>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
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 rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
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 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.
fn clear(&self) -> Painted<&T>
resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.§fn whenever(&self, value: Condition) -> Painted<&T>
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);