pub struct MonoAssembly(/* private fields */);Expand description
An opaque handle to a Mono runtime object.
§Thread safety
This type is intentionally !Send + !Sync. Every thread that reads or writes
Mono objects must first be registered with the runtime via
crate::MonoThreadGuard::attach. Using a handle on an unregistered thread is
undefined behavior — Mono’s garbage collector and internal bookkeeping assume all
active threads are known to the runtime.
Handles are therefore bound to the thread on which they were obtained. The
compiler enforces this: a handle cannot be moved to another thread without
explicit unsafe code.
If you need to transfer a handle across thread boundaries and you can guarantee that both threads are attached to the runtime for the entire duration of use, you can opt in manually on your wrapper type:
struct MyComponent {
class: mono_rt::MonoClass,
}
// SAFETY: `class` is only accessed while the calling thread holds a
// `MonoThreadGuard`, ensuring it is registered with the Mono runtime.
unsafe impl Send for MyComponent {}
unsafe impl Sync for MyComponent {}Implementations§
Source§impl MonoAssembly
impl MonoAssembly
Source§impl MonoAssembly
impl MonoAssembly
Sourcepub fn load_from_image(
image: MonoImage,
base_dir: Option<&str>,
) -> Result<Option<Self>>
pub fn load_from_image( image: MonoImage, base_dir: Option<&str>, ) -> Result<Option<Self>>
Registers a MonoImage as a fully loaded assembly in the current domain.
base_dir is the directory hint Mono uses to resolve dependent assemblies. Pass None
to rely on the standard assembly search path (correct for most injection scenarios).
§Errors
Returns MonoError::NullByteInName if base_dir contains an interior null byte.
Returns MonoError::ImageOpenFailed if Mono rejects the image.
Returns MonoError::Uninitialized if the Mono API has not been initialized.
Sourcepub fn close(self) -> Result<()>
pub fn close(self) -> Result<()>
Unloads this assembly from the runtime.
Call this during ejection after invoking the managed unload method. Using any handle
derived from this assembly after close is undefined behavior.
§Errors
Returns MonoError::Uninitialized if the Mono API has not been initialized.
Trait Implementations§
Source§impl Clone for MonoAssembly
impl Clone for MonoAssembly
Source§fn clone(&self) -> MonoAssembly
fn clone(&self) -> MonoAssembly
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more