pub enum MiraModule {
Native {
name: Rc<str>,
values: Rc<IndexMap<String, MiraAny>>,
},
// some variants omitted
}Expand description
A named collection of MiraScript-visible values.
Variants§
Native
A host-created module that may safely outlive an execution.
Implementations§
Source§impl MiraModule
impl MiraModule
Sourcepub fn new(name: impl Into<String>, values: IndexMap<String, MiraAny>) -> Self
pub fn new(name: impl Into<String>, values: IndexMap<String, MiraAny>) -> Self
Create a native module from an ordered map of exported values.
§Examples
use indexmap::IndexMap;
use mirascript_vm::{MiraAny, MiraModule};
let module = MiraModule::new(
"constants",
IndexMap::from([("answer".into(), MiraAny::Number(42.0))]),
);
assert_eq!(module.name(), "constants");
assert_eq!(module.get_native("answer"), Some(MiraAny::Number(42.0)));Sourcepub fn get_native(&self, key: &str) -> Option<MiraAny>
pub fn get_native(&self, key: &str) -> Option<MiraAny>
Clone an export from a native module.
Script modules return None; they are resolved by the active runtime.
Trait Implementations§
Source§impl Clone for MiraModule
impl Clone for MiraModule
Source§fn clone(&self) -> MiraModule
fn clone(&self) -> MiraModule
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MiraModule
impl Debug for MiraModule
Source§impl From<MiraModule> for MiraAny
impl From<MiraModule> for MiraAny
Source§fn from(value: MiraModule) -> Self
fn from(value: MiraModule) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl !RefUnwindSafe for MiraModule
impl !Send for MiraModule
impl !Sync for MiraModule
impl !UnwindSafe for MiraModule
impl Freeze for MiraModule
impl Unpin for MiraModule
impl UnsafeUnpin for MiraModule
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
Mutably borrows from an owned value. Read more