Struct wrapped_mono::method::Method

source ·
pub struct Method<Args: InteropSend + CompareClasses>where
    <Args as InteropSend>::TargetType: TupleToPtrs,{ /* private fields */ }
Expand description

Rust representation of a managed method(function of code loaded into mono runtime). Args - Tuple type of types of all arguments accepted by this particular method.

Implementations§

source§

impl<Args: InteropSend + CompareClasses> Method<Args>where <Args as InteropSend>::TargetType: TupleToPtrs,

Trait implemented only for Method type. Spiliting it from main Method type allows for different amount of method arguments.

source

pub fn get_ptr(&self) -> *mut MonoMethod

Gets the internal pointer to [MonoMethod].

Arguments
NameTypeDescription
self&MethodRust representation of a method to get pointer to.
source

pub fn can_acces_method<T: InteropSend + CompareClasses>( &self, called: &Method<T> ) -> boolwhere <T as InteropSend>::TargetType: TupleToPtrs,

Checks if method self can call method called.

Arguments
NameTypeDescription
self&MethodRust representation of the method preforming the call.
called&MethodRust representation of the method being called.
source

pub fn get_param_count(&self) -> u32

Counts number of parameters(arguments) this function accepts.

Arguments
NameTypeDescription
self&MethodRust representation of a method to get argument count of
source

pub fn get_from_name( class: &Class, name: &str, param_count: i32 ) -> Option<Self>

Gets method in class named name with param_count parameters. Returns None if could not find method or if its arguments did not match.

Arguments
NameTypeDescription
class&ClassClass the sought method belongs to
name&strName of the method
param_count&i32Ammount of parameters(arguments) method accepts
source

pub fn get_param_names(&self) -> Vec<String>

Gets names of all parameters method self accepts.

Arguments
NameTypeDescription
self&MethodRust representation of a method to get names of arguments off
source

pub fn get_params(&self) -> Vec<Class>

Returns list of classes of parameters of method self.

Arguments
NameTypeDescription
self&MethodRust representation of a method to get argument types off
source

pub fn get_return(&self) -> Class

Returns the return type of method self, if no return type returns System.Void

Arguments
NameTypeDescription
self&MethodRust representation of a method to get return type off
source§

impl<Args: InteropSend + CompareClasses> Method<Args>where <Args as InteropSend>::TargetType: TupleToPtrs,

source

pub fn invoke( &self, object: Option<Object>, args: Args ) -> Result<Option<Object>, Exception>

Invoke this method on object object with arguments args

Arguments
NameTypeDescription
self&SelfReference to method to invoke.
objectOption<Object>Object to invoke method on. Pass None if method is static.
argsArgsArguments to pass to method
Errors

Returns an exception if it was thrown by managed code.

source

pub unsafe fn from_ptr(met_ptr: *mut MonoMethod) -> Option<Self>

Creates new Method type from a [*mut MonoMethod], checks if arguments of [MonoMethod] and rust representation of a Method match and if not, returns None. Returns None if pointer is null or if method pointer points to has different signature.

Arguments
NameTypeDescription
met_ptr*mut [MonoMethod]Pointer to method to create a representation for.
Safety

Pointer must be either a valid pointer to [MonoMethod] recived from mono runtime, or a null pointer.

source

pub unsafe fn from_ptr_checked(met_ptr: *mut MonoMethod) -> Option<Self>

Creates new Method type from a [*mut MonoMethod], checks if arguments of [MonoMethod] and rust representation of a Method match and returns None if so. Returns None if pointer is null.

Arguments
NameTypeDescription
met_ptr*mut [MonoMethod]Pointer to method to create a representation for.
Safety

Pointer must be either a valid pointer to [MonoMethod] recived from mono runtime, or a null pointer.

Trait Implementations§

source§

impl<Args: InteropSend + CompareClasses> Sync for Method<Args>where <Args as InteropSend>::TargetType: TupleToPtrs,

Auto Trait Implementations§

§

impl<Args> RefUnwindSafe for Method<Args>where Args: RefUnwindSafe,

§

impl<Args> !Send for Method<Args>

§

impl<Args> Unpin for Method<Args>where Args: Unpin,

§

impl<Args> UnwindSafe for Method<Args>where Args: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.