Skip to main content

Module

Struct Module 

Source
pub struct Module { /* private fields */ }
Expand description

A handle to a dynamically loaded OSAL module (shared library).

This is a wrapper around an osal_id_t that will automatically call OS_ModuleUnload when it goes out of scope, preventing resource leaks.

Implementations§

Source§

impl Module

Source

pub fn load(name: &str, filename: &str, flags: ModuleFlags) -> Result<Self>

Loads a shared library object file into the running system.

GLOBAL_SYMBOLS is the default; use LOCAL_SYMBOLS for safer unloading, then use Module::symbol to look up local symbols.

§Arguments
  • name: A unique logical name to identify the module.
  • filename: The path to the object file to load (e.g., “/cf/my_lib.so”).
  • flags: Options for how symbols are loaded.
Source

pub fn symbol(&self, name: &str) -> Result<*mut c_void>

Looks up the address of a symbol within this module.

This is useful for finding function pointers in modules loaded with ModuleFlags::LOCAL_SYMBOLS.

§Safety

Using the returned pointer is inherently unsafe. The caller must ensure it is cast to the correct function pointer type and that the function signature is correct. The symbol’s lifetime is tied to the Module instance.

Source

pub fn id(&self) -> ModuleId

Returns the underlying ModuleId.

Source

pub fn info(&self) -> Result<ModuleProp>

Retrieves information about this module.

Trait Implementations§

Source§

impl Debug for Module

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Module

Source§

fn drop(&mut self)

Unloads the module when the Module object goes out of scope.

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