Skip to main content

ScriptCtx

Struct ScriptCtx 

Source
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

Source

pub fn with_argv<I, S>(argv: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Construct a context with the given argv. Used by the binary entry point; embedders may prefer to start from Default and populate argv directly.

Source

pub fn http(&mut self) -> &Agent

Return a shared HTTP agent, initializing on first use.

Trait Implementations§

Source§

impl Default for ScriptCtx

Source§

fn default() -> ScriptCtx

Returns the “default value” for a type. Read more

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.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.