Struct mun_runtime::Runtime
source · pub struct Runtime { /* private fields */ }
Expand description
A runtime for the Mun language.
Logging
The runtime uses log as a logging facade, but does not install a logger. To produce log output, you have to use a logger implementation compatible with the facade.
Implementations§
source§impl Runtime
impl Runtime
sourcepub fn builder<P: Into<PathBuf>>(library_path: P) -> RuntimeBuilder
pub fn builder<P: Into<PathBuf>>(library_path: P) -> RuntimeBuilder
Constructs a new RuntimeBuilder
to construct a new Runtime
instance.
sourcepub unsafe fn new(options: RuntimeOptions) -> Result<Runtime>
pub unsafe fn new(options: RuntimeOptions) -> Result<Runtime>
Constructs a new Runtime
that loads the library at library_path
and its
dependencies. The Runtime
contains a file watcher that is triggered with an interval
of dur
.
Safety
A munlib is simply a shared object. When a library is loaded, initialisation routines contained within it are executed. For the purposes of safety, the execution of these routines is conceptually the same calling an unknown foreign function and may impose arbitrary requirements on the caller for the call to be sound.
Additionally, the callers of this function must also ensure that execution of the termination routines contained within the library is safe as well. These routines may be executed when the library is unloaded.
See Assembly::load
for more information.
sourcepub fn get_function_definition(
&self,
function_name: &str
) -> Option<Arc<FunctionDefinition>>
pub fn get_function_definition(
&self,
function_name: &str
) -> Option<Arc<FunctionDefinition>>
Retrieves the function definition corresponding to function_name
, if available.
sourcepub fn get_type_info_by_name(&self, type_name: &str) -> Option<Type>
pub fn get_type_info_by_name(&self, type_name: &str) -> Option<Type>
Retrieves the type definition corresponding to type_name
, if available.
sourcepub fn get_type_info_by_id(&self, type_id: &TypeId<'_>) -> Option<Type>
pub fn get_type_info_by_id(&self, type_id: &TypeId<'_>) -> Option<Type>
Retrieve the type information corresponding to the type_id
, if available.
sourcepub unsafe fn update(&mut self) -> bool
pub unsafe fn update(&mut self) -> bool
Updates the state of the runtime. This includes checking for file changes, and reloading compiled assemblies.
Safety
A munlib is simply a shared object. When a library is loaded, initialisation routines contained within it are executed. For the purposes of safety, the execution of these routines is conceptually the same calling an unknown foreign function and may impose arbitrary requirements on the caller for the call to be sound.
Additionally, the callers of this function must also ensure that execution of the termination routines contained within the library is safe as well. These routines may be executed when the library is unloaded.
See Assembly::load
for more information.
sourcepub fn gc(&self) -> &MarkSweep<NoopObserver<Event>>
pub fn gc(&self) -> &MarkSweep<NoopObserver<Event>>
Returns a shared reference to the runtime’s garbage collector.
We cannot return an Arc
here, because the lifetime of data contained in GarbageCollector
is dependent on the Runtime
.
sourcepub fn gc_collect(&self) -> bool
pub fn gc_collect(&self) -> bool
Collects all memory that is no longer referenced by rooted objects. Returns true
if memory
was reclaimed, false
otherwise. This behavior will likely change in the future.
sourcepub fn construct_typed_array<'t, T: 't + Marshal<'t> + ArgumentReflection, I: IntoIterator<Item = T>>(
&'t self,
element_type: &Type,
iter: I
) -> ArrayRef<'t, T>where
I::IntoIter: ExactSizeIterator,
pub fn construct_typed_array<'t, T: 't + Marshal<'t> + ArgumentReflection, I: IntoIterator<Item = T>>(
&'t self,
element_type: &Type,
iter: I
) -> ArrayRef<'t, T>where
I::IntoIter: ExactSizeIterator,
Constructs an array with a predefined element type.
sourcepub fn construct_array<'t, T: 't + Marshal<'t> + HasStaticType, I: IntoIterator<Item = T>>(
&'t self,
iter: I
) -> ArrayRef<'t, T>where
I::IntoIter: ExactSizeIterator,
pub fn construct_array<'t, T: 't + Marshal<'t> + HasStaticType, I: IntoIterator<Item = T>>(
&'t self,
iter: I
) -> ArrayRef<'t, T>where
I::IntoIter: ExactSizeIterator,
Constructs an array from an iterator
source§impl Runtime
impl Runtime
sourcepub fn invoke<'runtime, 'ret, 'name, ReturnType: ReturnTypeReflection + Marshal<'ret> + 'ret, ArgTypes: InvokeArgs>(
&'runtime self,
function_name: &'name str,
arguments: ArgTypes
) -> Result<ReturnType, InvokeErr<'name, ArgTypes>>where
'runtime: 'ret,
pub fn invoke<'runtime, 'ret, 'name, ReturnType: ReturnTypeReflection + Marshal<'ret> + 'ret, ArgTypes: InvokeArgs>(
&'runtime self,
function_name: &'name str,
arguments: ArgTypes
) -> Result<ReturnType, InvokeErr<'name, ArgTypes>>where
'runtime: 'ret,
Invokes the Mun function called function_name
with the specified arguments
.