Skip to main content

BoundAssembly

Struct BoundAssembly 

Source
pub struct BoundAssembly {
    pub assembly_name: &'static str,
    pub assembly_path: &'static str,
    pub thunks_name: &'static str,
    pub coreclr_thunks: &'static [u8],
    pub mono_thunks: &'static [u8],
    pub function_count: usize,
    /* private fields */
}
Expand description

A .NET assembly bound with hao_runtime_macros::bind!.

Fields§

§assembly_name: &'static str

The bound assembly’s name, e.g. MyLib.

§assembly_path: &'static str

Where the bound assembly is loaded from; empty when the runtime already has it (a framework assembly).

§thunks_name: &'static str

The generated thunk assembly’s name.

§coreclr_thunks: &'static [u8]

The thunk assembly for CoreCLR, whose thunks are [UnmanagedCallersOnly].

§mono_thunks: &'static [u8]

The thunk assembly for Mono.

§function_count: usize

How many thunks there are, the helpers included.

Implementations§

Source§

impl BoundAssembly

Source

pub const fn new( assembly_name: &'static str, assembly_path: &'static str, thunks_name: &'static str, coreclr_thunks: &'static [u8], mono_thunks: &'static [u8], function_count: usize, ) -> Self

Describes a bound assembly; bind! generates this call, so there is usually no need to write it.

Source

pub fn load(&self, runtime: &Runtime) -> Result<()>

Loads the bound assembly and its thunks into runtime. Called on first use.

Source

pub fn function(&self, runtime: &Runtime, index: usize) -> Result<*const c_void>

A native pointer to thunk f{index}, loading the assembly and attaching the calling thread first. Call it with Runtime::backend’s calling convention.

Source

pub fn free(&self, runtime: &Runtime, handle: isize) -> Result<()>

Frees a GCHandle a thunk returned, letting the object be collected.

Source

pub fn take_string( &self, runtime: &Runtime, handle: isize, ) -> Result<Option<String>>

Reads and frees a handle to a System.String. 0 is null.

Source

pub fn object_to_string( &self, runtime: &Runtime, handle: isize, ) -> Result<String>

ToString() of the object behind handle, without freeing it.

Source

pub fn take_exception(&self, runtime: &Runtime, handle: isize) -> Error

Turns a handle to a thrown exception into an Error::Managed, freeing it.

Trait Implementations§

Source§

impl<'ʄ> Facet<'ʄ> for BoundAssembly

Available on crate feature reflect only.
Source§

const SHAPE: &'static Shape

The shape of this type, including: whether it’s a Struct, an Enum, something else? Read more

Auto Trait Implementations§

§

impl !Freeze for BoundAssembly

§

impl Forget for BoundAssembly

§

impl Move for BoundAssembly

§

impl RefUnwindSafe for BoundAssembly

§

impl Send for BoundAssembly
where &'static str: Send, &'static [u8]: Send, OnceLock<Vec<usize>>: Send, Mutex<()>: Send,

§

impl Sync for BoundAssembly

§

impl Unpin for BoundAssembly
where &'static str: Unpin, &'static [u8]: Unpin, Align4<u32>: Unpin, *const u8 is !null: Unpin, Align1<u8>: Unpin,

§

impl UnsafeUnpin for BoundAssembly

§

impl UnwindSafe for BoundAssembly
where &'static str: UnwindSafe, &'static [u8]: UnwindSafe, OnceLock<Vec<usize>>: UnwindSafe, Mutex<()>: UnwindSafe,

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

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more