Struct 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

Source

pub fn builder<P: Into<PathBuf>>(library_path: P) -> RuntimeBuilder

Constructs a new RuntimeBuilder to construct a new Runtime instance.

Source

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.

Source

pub fn get_function_definition( &self, function_name: &str, ) -> Option<Arc<FunctionDefinition>>

Retrieves the function definition corresponding to function_name, if available.

Source

pub fn get_type_info_by_name(&self, type_name: &str) -> Option<Type>

Retrieves the type definition corresponding to type_name, if available.

Source

pub fn get_type_info_by_id(&self, type_id: &TypeId<'_>) -> Option<Type>

Retrieve the type information corresponding to the type_id, if available.

Source

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.

Source

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.

Source

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.

Source

pub fn gc_stats(&self) -> Stats

Returns statistics about the garbage collector.

Source

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>

Constructs an array with a predefined element type.

Source

pub fn construct_array<'t, T: 't + Marshal<'t> + HasStaticType, I: IntoIterator<Item = T>>( &'t self, iter: I, ) -> ArrayRef<'t, T>

Constructs an array from an iterator

Source§

impl Runtime

Source

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.

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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