pub struct ScriptCtx {
pub argv: Vec<String>,
pub current_file: Option<PathBuf>,
pub required: HashSet<PathBuf>,
pub tests: Vec<TestCase>,
/* private fields */
}Fields§
§argv: Vec<String>Program arguments after the script path.
e.g. for tatara-script imports.tlisp lilitu_io --all → ["lilitu_io", "--all"].
current_file: Option<PathBuf>The file currently being evaluated (if any). Used by (require)
to resolve relative paths against the caller’s directory.
required: HashSet<PathBuf>Set of canonical absolute paths already required. Prevents
re-evaluation on the second (or third, …) (require …) of the
same file — required forms define globals once.
tests: Vec<TestCase>Recorded test cases when in --test mode. Each entry is a
(name, thunk-closure) pair — the closure captures the test body
for deferred execution.
Implementations§
Source§impl ScriptCtx
impl ScriptCtx
Sourcepub fn with_argv<I, S>(argv: I) -> Self
pub fn with_argv<I, S>(argv: I) -> Self
Construct a context with the given argv. Used by the binary
entry point; embedders may prefer to start from Default and
populate argv directly.
Sourcepub fn scratch_dir(&mut self) -> Result<PathBuf>
pub fn scratch_dir(&mut self) -> Result<PathBuf>
Mint a scratch DIRECTORY owned by this context.
The returned path is removed when the context drops. This is the only way the stdlib can obtain one.
§Errors
Propagates any create_dir_all failure.
Sourcepub fn scratch_file(&mut self) -> Result<PathBuf>
pub fn scratch_file(&mut self) -> Result<PathBuf>
Mint a scratch FILE (created empty) owned by this context.
The returned path is removed when the context drops. This is the only way the stdlib can obtain one.
§Errors
Propagates any write failure.
Sourcepub fn scratch_len(&self) -> usize
pub fn scratch_len(&self) -> usize
How many scratch entries this context currently owns. Test surface.