pub struct Executor { /* private fields */ }
Expand description
An executor interface for Macrosia.
Implementations§
Source§impl Executor
impl Executor
Sourcepub fn set_context(&self, context: u8) -> u8
pub fn set_context(&self, context: u8) -> u8
Sets the context in which this executor is running.
Sourcepub fn get_macro(&self, macro_name: &[u8]) -> Option<&dyn Macro>
pub fn get_macro(&self, macro_name: &[u8]) -> Option<&dyn Macro>
Gets a macro from the executor.
Sourcepub fn macros(
&self,
) -> &HashMap<Vec<u8>, Box<dyn Macro>, BuildHasherDefault<SeaHasher>>
pub fn macros( &self, ) -> &HashMap<Vec<u8>, Box<dyn Macro>, BuildHasherDefault<SeaHasher>>
Gets the map of all macros in the executor keyed with their names.
Sourcepub fn clear_macros(&mut self)
pub fn clear_macros(&mut self)
Adds a macro to the executor.
Sourcepub fn evaluate<'slf, 'reg: 'slf, 'buf: 'reg>(
&'slf self,
string: &'buf [u8],
reg: &'reg mut VariableRegistry,
step_limit: Option<usize>,
debug_log: Option<&mut Vec<String>>,
kill: &AtomicBool,
) -> impl FnMut() -> Option<Result<Cow<'buf, [u8]>, MacroError>>
pub fn evaluate<'slf, 'reg: 'slf, 'buf: 'reg>( &'slf self, string: &'buf [u8], reg: &'reg mut VariableRegistry, step_limit: Option<usize>, debug_log: Option<&mut Vec<String>>, kill: &AtomicBool, ) -> impl FnMut() -> Option<Result<Cow<'buf, [u8]>, MacroError>>
Evaluates a given bytestring, returning it with all macros expanded…
§Errors
…or an error if one occurred within one of the expanded macros.
§Why is the return like that.
If I had implemented this normally, this function may not terminate immediately - in fact, it may not terminate at all.
This returns a function that you can call to iterate one time over what would’ve been a loop.
The function will return a None
until it is done, and then a Some
containing the output value.
If you call the function after that, it will simply return a Some(Err(...))
.
Think of it like a Coroutine
.
Source§impl Executor
impl Executor
Sourcepub fn add_stdlib(&mut self)
pub fn add_stdlib(&mut self)
Adds all standard library macros to the given execution context.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Executor
impl !RefUnwindSafe for Executor
impl Send for Executor
impl Sync for Executor
impl Unpin for Executor
impl !UnwindSafe for Executor
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more