Struct wrapped_mono::Class

source ·
pub struct Class { /* private fields */ }
Expand description

Safe representation of a managed class.(eg. System.Int64, System.Object, etc.);

Implementations§

source§

impl Class

source

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

Returns copy of internal pointer representing [MonoClass].

source

pub unsafe fn from_ptr(class_ptr: *mut MonoClass) -> Option<Self>

Creates Class from class_ptr. If it is not null, returns Some, otherwise None.

Safety

class_ptr must me either a valid pointer to [MonoClass] or null pointer.

source

pub fn from_name(image: &Image, namespace: &str, name: &str) -> Option<Self>

Returns class named name in namespace in image image. Is not case sensitive!

Arguments
NameTypeDescription
image&Imageimage to load class from
namespace&strpath to namespace this class is in
name&strname of class to get
Example
// Not case sensitive!
let some_class = Class::from_name(&some_image,"SyStem","tyPe").expect("Could not find a class!");
source

pub fn from_name_case( image: &Image, namespace: &str, name: &str ) -> Option<Self>

Returns class named name in namespace in image image. It is case sensitive.

Arguments
NameTypeDescription
image&Imageimage to load class from
namespace&strpath to namespace this class is in
name&strname of class to get
Example
let some_class = Class::from_name_case(&some_image,"System","Type").expect("Could not find a class!");
source

pub fn get_field_from_name(&self, name: &str) -> Option<ClassField>

Gets field name of class.

Safety

Getters, Setters, and Indexers are not fields of classes!;

Example
C#
 class SomeClass{
     int someField;    
 }
Rust
 let some_field = some_class.get_field_from_name("Delimiter").expect("Could not find field!");
source

pub fn get_name(&self) -> String

Returns name of this class

source

pub fn get_image(&self) -> Image

Gets the image this class exists in.

source

pub fn array_element_size(&self) -> i32

Returns amount of memory occupied by object when inside array.

source

pub fn get_interfaces(&self) -> Vec<Self>

Gets a Vec containing all interfaces this class implements.

source

pub fn get_namespace(&self) -> String

Gets namespace this class is in, or “” string if it is not in any namespace.

source

pub fn get_nesting_type(&self) -> Option<Self>

Gets class this class is nested in, or None if it is not nested in any type.

source

pub fn get_parent(&self) -> Option<Self>

Gets type this class derives from or None if it does not derive any type.

Example

For a class SomeClass

C#
 class SomeClass:SomeparentClass{
    
 }

Function will return SomeParentClass

source

pub fn get_rank(&self) -> i32

Gets number of dimensions of array.

Constrains

self must be an array type, otherwise returns 0.

source

pub fn data_size(&self) -> i32

Return size of static data of this class

source

pub fn get_element_class(&self) -> Self

Get element class of an array. self must be an array type, otherwise returns self.

source

pub fn implements_interface(&self, iface: &Self) -> bool

Returns if class implements interface iface.

source

pub fn is_assignable_from(&self, other: &Self) -> bool

Returns true if object of type other can be assigned to class self.

source

pub fn is_delegate(&self) -> bool

Checks if self represents a delegate type.

source

pub fn is_enum(&self) -> bool

Checks if self represents an enumeration type.

source

pub fn num_fields(&self) -> i32

Gets amount of static and instance files of class

source

pub fn num_methods(&self) -> i32

Gets amount of methods in the class self

source

pub fn num_properties(&self) -> i32

Gets number of properties in the class(getters,setters,indexers)

source

pub fn is_valuetype(&self) -> bool

Checks if self represents a value type.

source

pub fn get_object() -> Self

Returns Class representing System.Object type.

source

pub fn get_int_16() -> Self

Returns Class representing System.Int16 type (i16).

source

pub fn get_int_32() -> Self

Returns Class representing System.Int32 type (i32).

source

pub fn get_int_64() -> Self

Returns Class representing System.Int64 type (i64).

source

pub fn get_double() -> Self

Returns Class representing System.Double type (f64).

source

pub fn get_enum() -> Self

Returns Class representing System.Enum type.

source

pub fn get_int_ptr() -> Self

Returns Class representing System.IntPtr type (isize).

source

pub fn get_sbyte() -> Self

Returns Class representing System.SByte type (i8).

source

pub fn get_single() -> Self

Returns Class representing System.Single type (f32).

source

pub fn get_string() -> Self

Returns Class representing System.String type.

source

pub fn get_thread() -> Self

Returns Class representing System.Threading.Thread type.

source

pub fn get_uint_16() -> Self

Returns Class representing System.UInt16 type(u16).

source

pub fn get_uint_32() -> Self

Returns Class representing System.UInt32 type(u32).

source

pub fn get_uint_64() -> Self

Returns Class representing System.UInt64 type(u64).

source

pub fn get_uint_ptr() -> Self

Returns Class representing System.UIntPtr type (usize).

source

pub fn get_void() -> Self

Returns Class representing System.Void type.

source

pub fn get_array() -> Self

Returns Class representing System.Array type.

source

pub fn get_boolean() -> Self

Returns Class representing System.Boolean type (bool).

source

pub fn get_byte() -> Self

Returns Class representing System.Byte type (u8).

source

pub fn get_char() -> Self

Returns Class representing System.Char type (char).

source

pub fn get_array_class(&self, rank: u32) -> Self

Gets class of an array of class self with rank (for int and rank 1, returns int[], for byte and rank 3 returns byte[][][],etc.)

source

pub fn get_exception_class() -> Self

Returns Class representing the type System.Exception.

source

pub fn get_delegate_class() -> Self

Returns Class representing the type System.Delegate.

source

pub fn get_fields(&self) -> Vec<ClassField>

Returns all fields of a class

source

pub fn get_field(&self, name: &str) -> Option<ClassField>

Returns field with name name

source

pub fn get_nested_types(&self) -> Vec<Self>

Gets all types nested inside this class.

source

pub fn get_property_from_name(&self, name: &str) -> Option<ClassProperity>

Returns property with name name or None if it is not inside class.

source

pub fn get_properities(&self) -> Vec<ClassProperity>

Returns all properties of class self.

source

pub fn get_name_sig(&self) -> String

Returns for use in : “NAMESPACE.NAME”

Trait Implementations§

source§

impl Clone for Class

source§

fn clone(&self) -> Class

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Class

source§

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

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

impl From<Class> for ReflectionType

source§

fn from(class: Class) -> Self

Converts to this type from the input type.
source§

impl PartialEq<Class> for Class

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for Class

source§

impl Eq for Class

source§

impl StructuralEq for Class

source§

impl Sync for Class

Auto Trait Implementations§

§

impl RefUnwindSafe for Class

§

impl !Send for Class

§

impl Unpin for Class

§

impl UnwindSafe for Class

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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.