pub struct WorkerLayout { /* private fields */ }Expand description
Where each context’s generated files go.
Implementations§
Source§impl WorkerLayout
impl WorkerLayout
Sourcepub fn for_project(
project_root: &Path,
overlay: &HashMap<PathBuf, String>,
) -> Self
pub fn for_project( project_root: &Path, overlay: &HashMap<PathBuf, String>, ) -> Self
The layout a project’s build uses, from its bynk.toml (with overlay
over the files on disk). The one place the build, the checker and the
editor learn where each context’s Worker is, so they cannot disagree.
A manifest with no [deploy.workers] table, or one that does not read
(the manifest checks report that), is Self::identity.
Sourcepub fn from_groups(groups: &WorkerGroups) -> Self
pub fn from_groups(groups: &WorkerGroups) -> Self
The layout of groups: a member goes in its group’s directory, under a
prefix; every other context is as in Self::identity.
Sourcepub fn is_member(&self, context: &str) -> bool
pub fn is_member(&self, context: &str) -> bool
Whether context is a member of a group, so its entry is one of several
behind the group’s dispatcher and marks the requests it does not own.
Sourcepub fn dir(&self, context: &str) -> String
pub fn dir(&self, context: &str) -> String
The directory name, under workers/, of the Worker context is in.
Sourcepub fn script_name(&self, context: &str) -> String
pub fn script_name(&self, context: &str) -> String
The name of the Worker context is in on Cloudflare: what a Service
Binding to it, and its own wrangler.toml, call it. The group’s name
or key for a member, the dashed context name otherwise. (The directory
and the names derived for its resources stay the key, the group’s
identity, so that renaming a script does not move them.)
Sourcepub fn groups(&self) -> impl Iterator<Item = (&str, &[String])>
pub fn groups(&self) -> impl Iterator<Item = (&str, &[String])>
Every group, by its directory (the group’s key), with its members in the order the manifest lists them.
Sourcepub fn group_members(&self, dir: &str) -> Option<&[String]>
pub fn group_members(&self, dir: &str) -> Option<&[String]>
The members of the group whose directory is dir, in the order the
manifest lists them; None for a context’s own Worker.
Sourcepub fn worker_file(&self, context: &str, name: &str) -> PathBuf
pub fn worker_file(&self, context: &str, name: &str) -> PathBuf
The path of a file that belongs to the Worker as a whole (index.ts,
wrangler.toml): workers/<dir>/<name>.
Sourcepub fn member_file(&self, context: &str, name: &str) -> PathBuf
pub fn member_file(&self, context: &str, name: &str) -> PathBuf
The path of one of context’s own files: workers/<dir>/<name>, or,
when other contexts share the directory, workers/<dir>/<member>.<name>.
Sourcepub fn own_module_specifier(&self, context: &str, name: &str) -> String
pub fn own_module_specifier(&self, context: &str, name: &str) -> String
The import specifier, from a module in context’s Worker directory, of
one of its own files: ./<name> stripped of its extension and given
.js, with the member prefix in a group (./shop-orders.compose.js).
Sourcepub fn handlers_source_path(&self, context: &str) -> PathBuf
pub fn handlers_source_path(&self, context: &str) -> PathBuf
The project-relative synthetic source path of context’s handlers
module, which the emitter’s relative-import machinery resolves against.
Sourcepub fn handlers_output_path(&self, context: &str) -> PathBuf
pub fn handlers_output_path(&self, context: &str) -> PathBuf
The project-relative output path of context’s handlers module.
Sourcepub fn file_source_path(&self, context: &str, source: &Path) -> PathBuf
pub fn file_source_path(&self, context: &str, source: &Path) -> PathBuf
The synthetic source path of one file’s module in a context split across
files (#1820): handlers/<stem>.bynk beside the handlers barrel.
Sourcepub fn own_handlers_specifier(&self, context: &str) -> String
pub fn own_handlers_specifier(&self, context: &str) -> String
The specifier by which one of context’s own modules (its compose and
entry) imports its handlers module: ./handlers.js, or
./<member>.handlers.js in a group.
Sourcepub fn handlers_specifier(&self, from: &str, to: &str) -> String
pub fn handlers_specifier(&self, from: &str, to: &str) -> String
The import specifier, from a module in from’s Worker directory, of
to’s handlers module: ../<dir>/handlers.js across Workers,
./<member>.handlers.js within one.
Trait Implementations§
Source§impl Clone for WorkerLayout
impl Clone for WorkerLayout
Source§fn clone(&self) -> WorkerLayout
fn clone(&self) -> WorkerLayout
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for WorkerLayout
impl Debug for WorkerLayout
Source§impl Default for WorkerLayout
impl Default for WorkerLayout
Source§fn default() -> WorkerLayout
fn default() -> WorkerLayout
Source§impl PartialEq for WorkerLayout
impl PartialEq for WorkerLayout
impl Eq for WorkerLayout
impl StructuralPartialEq for WorkerLayout
Auto Trait Implementations§
impl Freeze for WorkerLayout
impl RefUnwindSafe for WorkerLayout
impl Send for WorkerLayout
impl Sync for WorkerLayout
impl Unpin for WorkerLayout
impl UnsafeUnpin for WorkerLayout
impl UnwindSafe for WorkerLayout
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<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);