Struct State

Source
pub struct State {
    pub storage: Storage,
    pub stdin: Box<dyn BufRead>,
    pub stdout: WriteHandle,
    pub stderr: WriteHandle,
    /* private fields */
}

Fields§

§storage: Storage§stdin: Box<dyn BufRead>§stdout: WriteHandle§stderr: WriteHandle

Implementations§

Source§

impl State

Source

pub fn new() -> Self

Creates a new state for running a program.

You must use a method such as with_code or with_source_file to set the program source code before using run to execute it.

Source

pub fn with_code(self, code: impl AsRef<str>) -> Self

Sets the code that will be executed.

Source

pub fn with_source_file(self, path: impl AsRef<Path>) -> Result<Self>

Sets both the code and the current directory by reading from the given file path.

§Errors

Returns an error if reading from the file failed.

§Panics

Panics if the path is invalid.

Source

pub fn with_source_directory(self, dir_path: impl AsRef<Path>) -> Self

Sets the source directory for resolving imports to the given directory.

Source

pub fn with_cwd(self) -> Self

Sets the current directory to the operating systems current working directory.

§Panics

Panics if env::current_dir returned an error.

Source

pub fn run(&mut self) -> Result<Atom>

Runs the given program with the details specified by this state.

Returns the result the program returned.

§Panics

Panics if code was not set.

Source

pub const fn make_type_id(&mut self) -> i64

Returns a new type id for a type call.

Trait Implementations§

Source§

impl Default for State

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl Freeze for State

§

impl !RefUnwindSafe for State

§

impl !Send for State

§

impl !Sync for State

§

impl Unpin for State

§

impl !UnwindSafe for State

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