Skip to main content

EmitProjectCtx

Struct EmitProjectCtx 

Source
pub struct EmitProjectCtx {
Show 36 fields pub source_path: PathBuf, pub identity_path: String, pub commons_name: String, pub file_decl_index: FileDeclIndex, pub imported_from: HashMap<String, String>, pub imported_from_kind: HashMap<String, UnitKind>, pub imported_decl_paths: HashMap<String, HashMap<String, PathBuf>>, pub consumed_type_aliases: HashMap<String, String>, pub unit_kind: UnitKind, pub owning_context: Option<String>, pub exports_for_consumed: HashMap<String, HashMap<String, Visibility>>, pub cross_context: CrossContextInfo, pub target: BuildTarget, pub local_agents: HashSet<String>, pub agent_given_deps: HashMap<String, String>, pub agent_given_deps_names: HashMap<String, Vec<String>>, pub extra_imports: Vec<ExtraImport>, pub agent_method_givens: HashMap<String, HashMap<String, Vec<CapRefIr>>>, pub agent_called_contexts: Vec<String>, pub actors: HashMap<String, ActorDecl>, pub event_schema_versions: HashMap<String, i64>, pub agent_schema_versions: HashMap<String, AgentVersions>, pub consumed_adapters: HashSet<String>, pub consumed_types_with_methods: HashSet<String>, pub import_ext: ImportExt, pub contracts: bool, pub trace: Option<TraceLoc>, pub inspect_agents: bool, pub history_target_agents: HashSet<String>, pub asset_served: BTreeMap<String, String>, pub embed_text: BTreeMap<String, String>, pub imported_methods: HashMap<String, Vec<FnSig>>, pub runtime_use: RuntimeUse, pub worker_layout: WorkerLayout, pub unit_source: Option<UnitSource>, pub type_spellings: HashMap<String, String>,
}

Fields§

§source_path: PathBuf

Source path of the file being emitted (relative to project root).

§identity_path: String

The file’s project-relative identity path, as the test runner reports it in an expect’s location. A violated declaration’s location is built from it (#2272).

§commons_name: String

Joined name of the commons or context this file belongs to.

§file_decl_index: FileDeclIndex

Which file declares each name in the local unit.

§imported_from: HashMap<String, String>

For each imported name, the joined name of the unit it came from.

§imported_from_kind: HashMap<String, UnitKind>

For each imported name, the kind (commons vs context) of the source unit.

§imported_decl_paths: HashMap<String, HashMap<String, PathBuf>>

For each imported unit, the file path that declares each name.

§consumed_type_aliases: HashMap<String, String>

#2887: the types this unit renames with consumes U { T as Alias }, alias → the name the consumed module declares it under.

§unit_kind: UnitKind

What kind of unit this is.

§owning_context: Option<String>

For contexts: this context’s qualified name (used as the brand for rebranded mixed-in types and exported types).

§exports_for_consumed: HashMap<String, HashMap<String, Visibility>>

For contexts: exports of each consumed context (so the emitter knows which names to import and how).

§cross_context: CrossContextInfo

For contexts: full cross-context information (consumed contexts, aliases, consumed services and types). Mirrors what the resolver and checker see (v0.6).

§target: BuildTarget

v0.8 build target. Workers mode reroutes cross-context calls through Service Bindings and adds per-Worker entry/composition artefacts.

§local_agents: HashSet<String>

Agent names declared in this unit. The body lowering uses this set to recognise Agent(key) construction and agent_instance.method(...) dispatch.

§agent_given_deps: HashMap<String, String>

#527: for each local agent with given capabilities, the TS expression building those deps DO-side (workers contexts only; the DO wire cannot carry providers). Consumed by emit_agent’s fetch branch.

§agent_given_deps_names: HashMap<String, Vec<String>>

1A.36b-2: for each agent in agent_given_deps, the namespaces its expression spells (bynk__binding, handlers_shop_orders), declared with the text so the module’s imports follow its tree.

§extra_imports: Vec<ExtraImport>

#527: extra imports handlers.ts needs for the expressions above.

§agent_method_givens: HashMap<String, HashMap<String, Vec<CapRefIr>>>

#527: for each local agent, each on call method’s given capability list. The lowering records which agent methods a handler body calls so the handler’s emitted deps type carries the callee’s capabilities — the runtime deps value (built by compose) always did.

§agent_called_contexts: Vec<String>

#1961: the consumed contexts the context’s agents call (emitter::agent_cross_context_targets), unit-wide. A handler that constructs an agent names them in its deps.env type.

§actors: HashMap<String, ActorDecl>

v0.47: the context’s actor declarations (merged across files), keyed by name. Used to resolve a handler’s Bearer verification seam in emit.rs regardless of which file declares the actor.

§event_schema_versions: HashMap<String, i64>

Events slice 3b (#978): each locally-declared event’s resolved @schema(N) version (or 1 if absent), merged across files the same way actors is above — Events.emit[E]’s lowering site only has E’s bare name (the turbofish type argument), never its declaration, so this is threaded down to ModuleCtx/LowerCtx rather than re-derived from the per-file synthetic Commons lower.rs otherwise sees (which would silently miss an event declared in a sibling file).

§agent_schema_versions: HashMap<String, AgentVersions>

State-migrations S1 (#2211): each locally-declared agent’s lock version and oldest readable stored version, keyed by agent name. Empty when the build has no lock (SchemaLock::Off), in which case the agent emits no version logic at all (Decision A).

§consumed_adapters: HashSet<String>

v0.17: consumed unit names that are adapters. An adapter is not a Worker, so in workers mode its capability types are imported from its root module (<adapter>.ts), not from a per-Worker handlers.ts.

§consumed_types_with_methods: HashSet<String>

#2045: the types of consumed contexts (adapters aside) that carry attached methods. A call to one (b.big() lowers to Batch.big(b)) runs the callee’s own code from its companion object, so that name is a real value import; every other consumed context type imports type-only.

§import_ext: ImportExt

Slice 2: the extension emitted import specifiers use (.js default; .ts for the bynk test --inspect debug build). Consulted by runtime_import_for and the sibling/cross-commons specifier helpers.

§contracts: bool

v0.115 (testing track slice 3): emit the function-contract call-site guard (dev/test profile). Stripped in the deploy build for zero runtime cost.

§trace: Option<TraceLoc>

#3580: Some emits the per-request trace recording (bynk dev --trace-events): the cross-context, agent and capability sites wrapped in __traceStep, and the Worker’s fetch in __traceFetch. Never set by a deploy build, whose output is byte-identical.

§inspect_agents: bool

#3581: emit the dev-only agent inspection (the instance recording in each agent factory and the /_bynk/inspect branch of each agent). false for every build but bynk dev, so a deploy build is byte-identical.

§history_target_agents: HashSet<String>

v0.119 (testing track slice 7, ADR 0155): agent names a for all run: History[Agent] property in this project drives. Only these agents gain the exported __bynkDriveHistory_<Agent> test-support driver — every other agent’s emission is byte-for-byte unchanged.

§asset_served: BTreeMap<String, String>

#1883, slice 1b: each declared asset’s served URL path, keyed by its normalised source path (assets::declared_served_paths) — the value of the asset’s .url.

§embed_text: BTreeMap<String, String>

#2387, slice 2: each declared embed’s text, keyed by its normalised source path (embeds::read_declared_embeds) — the value of the embed’s constant.

§imported_methods: HashMap<String, Vec<FnSig>>

v0.132.1 (#481): for a context, the user-defined attached methods of each uses-imported refined/opaque type, keyed by the type’s name and sorted by method name. The context’s own TypedCommons merges the imported types but not their fn items, so emit_context_rebrands reads this to forward Cents.fromInt(…) and friends onto the rebranded const. Empty for commons units and for contexts with no such imports.

P6.18: each entry is a resolved FnSig (the declaring unit’s own params/return_ty, already TyId-typed), not a raw FnDecl — see build_emit_unit_ctx’s own doc comment for why.

§runtime_use: RuntimeUse

Which conditional runtime.ts helpers this file’s emission referenced.

Unlike every field above, this is an output, not an input: emission writes it (through &self, via interior mutability) and the header / import post-pass reads it back. It rides on the context because the producers — the Bytes kernel in lower, the boundary codecs in serialisation, the ICU formatters in emit — already receive &ctx, so no other signature has to change to carry the fact up.

One EmitProjectCtx is built per emitted file, immediately before its emit_project call, so the flags cannot leak between files. Replaces a substring scan of the generated text; see emitter::runtime_use.

§worker_layout: WorkerLayout

#3562: where each context’s generated files go on Workers.

§unit_source: Option<UnitSource>

#2620: the unit’s source and identity path; None for single-file emission.

§type_spellings: HashMap<String, String>

#1927: a uses-imported type this unit hides behind its own value (a function, asset, service, agent or provider of the same name), type name to the inline import type that names it, import("<module>").Name. Empty for a unit that hides none.

Implementations§

Source§

impl EmitProjectCtx

Source

pub fn consumed_context_types(&self) -> HashSet<String>

#2045: on workers, the types this unit imports from a consumed context (not an adapter): each is another Worker’s, so this module names it in type position only and builds its sum variants inline.

Source

pub fn commons_path(name: &str) -> PathBuf

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

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

§

fn fg(&self, value: Color) -> Painted<&T>

Returns a styled value derived from self with the foreground set to value.

This method should be used rarely. Instead, prefer to use color-specific builder methods like red() and green(), which have the same functionality but are pithier.

§Example

Set foreground color to white using fg():

use yansi::{Paint, Color};

painted.fg(Color::White);

Set foreground color to white using white().

use yansi::Paint;

painted.white();
§

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

fn bg(&self, value: Color) -> Painted<&T>

Returns a styled value derived from self with the background set to value.

This method should be used rarely. Instead, prefer to use color-specific builder methods like on_red() and on_green(), which have the same functionality but are pithier.

§Example

Set background color to red using fg():

use yansi::{Paint, Color};

painted.bg(Color::Red);

Set background color to red using on_red().

use yansi::Paint;

painted.on_red();
§

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

fn attr(&self, value: Attribute) -> Painted<&T>

Enables the styling [Attribute] value.

This method should be used rarely. Instead, prefer to use attribute-specific builder methods like bold() and underline(), which have the same functionality but are pithier.

§Example

Make text bold using attr():

use yansi::{Paint, Attribute};

painted.attr(Attribute::Bold);

Make text bold using using bold().

use yansi::Paint;

painted.bold();
§

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

fn quirk(&self, value: Quirk) -> Painted<&T>

Enables the yansi [Quirk] value.

This method should be used rarely. Instead, prefer to use quirk-specific builder methods like mask() and wrap(), which have the same functionality but are pithier.

§Example

Enable wrapping using .quirk():

use yansi::{Paint, Quirk};

painted.quirk(Quirk::Wrap);

Enable wrapping using wrap().

use yansi::Paint;

painted.wrap();
§

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

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

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

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

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

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

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

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

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

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

👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear(). The clear() method will be removed in a future release.

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

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

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

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

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

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

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

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

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

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

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

fn whenever(&self, value: Condition) -> Painted<&T>

Conditionally enable styling based on whether the [Condition] value applies. Replaces any previous condition.

See the crate level docs for more details.

§Example

Enable styling painted only when both stdout and stderr are TTYs:

use yansi::{Paint, Condition};

painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);
§

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

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

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

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

impl<T, 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.