pub struct Module {
pub code_object: Rc<CodeObject>,
pub slots: Slots,
}
Expand description
Main runtime representation for loadable modules.
Fields§
§code_object: Rc<CodeObject>
Always required. Shared object libraries will only fill the name
and loc
attribute.
slots: Slots
Contains CallProtocol
entries that will be added to the context.
Implementations§
Source§impl Module
impl Module
Sourcepub fn is_loadable<T>(path: T) -> Result<bool, Lovm2Error>
pub fn is_loadable<T>(path: T) -> Result<bool, Lovm2Error>
A module is loadable if the first four bytes of the file are either the ELF
magic number (shared object) or the lovm2
magic number LV2_MAGIC_NUMBER.
Sourcepub fn load_from_file<T>(path: T) -> Result<Module, Lovm2Error>
pub fn load_from_file<T>(path: T) -> Result<Module, Lovm2Error>
Checks if the file is loadable and tries creating a module from it.
Sourcepub fn location(&self) -> Option<&String>
pub fn location(&self) -> Option<&String>
Returns the filesystem path from which the module was created.
pub fn slots(&self) -> &Slots
Sourcepub fn slot(&self, name: &Variable) -> Option<Rc<dyn CallProtocol>>
pub fn slot(&self, name: &Variable) -> Option<Rc<dyn CallProtocol>>
Try looking up a Callable
by name.
Sourcepub fn store_to_file<T>(&self, path: T) -> Result<(), Lovm2Error>
pub fn store_to_file<T>(&self, path: T) -> Result<(), Lovm2Error>
Write the contained CodeObject
into a file. This wil do nothing
for shared object modules.
Trait Implementations§
Source§impl From<CodeObject> for Module
impl From<CodeObject> for Module
Source§fn from(code_object: CodeObject) -> Module
fn from(code_object: CodeObject) -> Module
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for Module
impl !RefUnwindSafe for Module
impl !Send for Module
impl !Sync for Module
impl Unpin for Module
impl !UnwindSafe for Module
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