Struct ContextBuilder

Source
pub struct ContextBuilder { /* private fields */ }
Expand description

Configures an Engine about a specific script to compile, this includes giving input variables

Implementations§

Source§

impl ContextBuilder

Source

pub fn new() -> Self

Creates a new empty ContextBuilder

Source

pub fn push_variable<Variable: Into<InputVariable>>( &mut self, variable: Variable, ) -> (usize, usize)

Pushes an input variable, if said it’s constant, the AST will have its value inlined

Source

pub fn with_variable<Variable: Into<InputVariable>>( self, variable: Variable, ) -> ContextBuilder

Adds an input variable, if said it’s constant, the AST will have its value inlined

Source

pub fn start_parsing_position_offset( &mut self, line_offset: usize, column_offset: usize, )

Specifies an starting position for this script, this is useful if you use a file with multiple scripts for managing error.

Example: If you had a file containing multiples scripts, and one was located on the line 100 and had a syntax / AST Parsing on it’s 3rd line, then the error will tell the error happens on line 103, instead of line 3.

Source

pub fn with_start_parsing_position_offset( self, line_offset: usize, column_offset: usize, ) -> ContextBuilder

Specifies an starting position for this script, this is useful if you use a file with multiple scripts for managing error.

Example: If you had a file containing multiples scripts, and one was located on the line 100 and had a syntax / AST Parsing on it’s 3rd line, then the error will tell the error happens on line 103, instead of line 3.

Source

pub fn parsing_column_fixed(&mut self, parsing_position_column_is_fixed: bool)

Specifies it the column indicated in Self::with_start_parsing_position_offset is a fixed one or not.

Example: If you had a file containing a script, but it is idented by 4 spaces on every line, setting this to true and setting the column offset as 4 would make that errors happening on colum 4 would appear as they happened on column 0 instead, so if the error its on column 100, it would say the error starts at 96 instead.

Source

pub fn with_parsing_column_fixed( self, parsing_position_column_is_fixed: bool, ) -> ContextBuilder

Specifies it the column indicated in Self::with_start_parsing_position_offset is a fixed one or not.

Example: If you had a file containing a script, but it is idented by 4 spaces on every line, setting this to true and setting the column offset as 4 would make that errors happening on colum 4 would appear as they happened on column 0 instead, so if the error its on column 100, it would say the error starts at 96 instead.

Trait Implementations§

Source§

impl AsRef<ContextBuilder> for ContextBuilder

Source§

fn as_ref(&self) -> &ContextBuilder

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for ContextBuilder

Source§

fn clone(&self) -> ContextBuilder

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ContextBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ContextBuilder

Source§

fn default() -> Self

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.