pub struct Worker { /* private fields */ }Expand description
A running worker. Dropping it closes Node’s stdin, waits up to 2 s for it to exit, then kills it.
Implementations§
Source§impl Worker
impl Worker
Sourcepub fn start(
node: &NodeInfo,
root: &Path,
run_mode: RunMode,
) -> Result<Worker, WorkerError>
pub fn start( node: &NodeInfo, root: &Path, run_mode: RunMode, ) -> Result<Worker, WorkerError>
Start Node with the worker, in root (the project folder), with
11ty’s environment variables added to Brrrty’s own.
Trait Implementations§
Source§impl JsRuntime for Worker
impl JsRuntime for Worker
Source§fn set_argument(&mut self, arg: &Value) -> JsResult<()>
fn set_argument(&mut self, arg: &Value) -> JsResult<()>
The data 11ty hands an exported function (
addGlobalData values and
eleventy), sent once before any file loads.Source§fn load(&mut self, file: &Path, call: bool) -> JsResult<Decoded>
fn load(&mut self, file: &Path, call: bool) -> JsResult<Decoded>
Import
file (absolute) as 11ty does; when call and the export is
a function, call it with the argument and await it.Source§fn call(
&mut self,
f: FnHandle,
this: This<'_>,
args: &[Value],
settle: Settle,
) -> JsResult<Decoded>
fn call( &mut self, f: FnHandle, this: This<'_>, args: &[Value], settle: Settle, ) -> JsResult<Decoded>
Call a function value from a template with
this and args.Source§fn page_open(
&mut self,
data: &Value,
traps: &[(String, String)],
defaults: &[String],
) -> JsResult<PageId>
fn page_open( &mut self, data: &Value, traps: &[(String, String)], defaults: &[String], ) -> JsResult<PageId>
Keep
data as a page’s data object. Each of traps (a top-level
key and why) is a key Brrrty can’t supply: reading it refuses the
call. Each of defaults (a dotted computed key) that is undefined
is set to "", as 11ty’s computed data proxy does.Source§fn page_vars(
&mut self,
page: PageId,
f: FnHandle,
keys: &[String],
) -> JsResult<Vec<String>>
fn page_vars( &mut self, page: PageId, f: FnHandle, keys: &[String], ) -> JsResult<Vec<String>>
The keys
f reads of the page’s data, as 11ty’s
ComputedDataProxy.findVarsUsed finds them (keys are the page’s
computed keys).Source§fn page_call(
&mut self,
page: PageId,
f: FnHandle,
set: Option<&str>,
) -> JsResult<Decoded>
fn page_call( &mut self, page: PageId, f: FnHandle, set: Option<&str>, ) -> JsResult<Decoded>
Call
f with the page’s data, as 11ty calls a computed function or
a permalink function, awaiting it; with set, store the result at
that dotted key of the page’s data.Source§fn page_set(&mut self, page: PageId, key: &str, value: &Value) -> JsResult<()>
fn page_set(&mut self, page: PageId, key: &str, value: &Value) -> JsResult<()>
Set a dotted key of the page’s data, as 11ty’s
lodash.set does.Source§fn page_close(&mut self, page: PageId)
fn page_close(&mut self, page: PageId)
Forget the page’s data.
Source§fn loads_changed(&mut self) -> JsResult<Vec<(PathBuf, Decoded)>>
fn loads_changed(&mut self) -> JsResult<Vec<(PathBuf, Decoded)>>
The global data files are loaded: each of their values that a later
one changed (by its file), as it is now, which is what 11ty’s pages
see.
Source§fn begin_calls(&mut self) -> JsResult<()>
fn begin_calls(&mut self) -> JsResult<()>
The data files are loaded; what follows are the pages’ calls.
Refused when a template or directory data file changed a value
another file gave, or a built-in prototype.Auto Trait Implementations§
impl !RefUnwindSafe for Worker
impl !Sync for Worker
impl !UnwindSafe for Worker
impl Forget for Worker
impl Freeze for Worker
impl Move for Worker
impl Send for Worker
impl Unpin for Worker
impl UnsafeUnpin for Worker
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
Mutably borrows from an owned value. Read more