Struct wrapped_mono::Exception

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

Safe representation of MonoException.

Implementations§

source§

impl Exception

source

pub unsafe fn raise(&self) -> !

Raise exception (it can be then cached by catch clause in managed code)

Safety

This function is extremely unsafe, because when it is called, drop functions of local variables are not automatically called.

Example
C#
 using System.Runtime.CompilerServices;
 class SomeClass{
     [MethodImplAttribute(MethodImplOptions.InternalCall)]   
     void ExceptionThrower();
     void SomeMethod(){
         try{
             ExceptionThrower();
         }
         catch(exception){
             Console.WriteLine("This will always catch exceptions raised in ExceptionThrower");
         }
     }
 }
Rust
 #[invokable]
 fn exception_thrower(){
     let some_local_data = vec![12,2,35,32];
     let exception = Exception::not_implemented("This function will just throw exceptions!");
     // Everything needs to be dropped before exception is thrown!
     drop(some_local_data);
     unsafe{exception.raise()};
 }
source

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

Creates Exception of type name in namespace from image in domain

source

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

Creates Exception of type name in namespace from image

source

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

Creates Exception of type name in namespace from image with message msg.

source

pub fn argument_exception(arg: &str, msg: &str) -> Self

Returns Exception that is instance of System.ArgumentException

source

pub fn not_implemented(msg: &str) -> Self

Returns Exception that is instance of System.NotImplementedException

source

pub fn argument_null(msg: &str) -> Self

Returns Exception that is instance of System.ArgumentNullException

source

pub fn argument_out_of_range(msg: &str) -> Self

Returns Exception that is instance of System.ArgumentOutOfRangeException

source

pub fn arithmetic() -> Self

Returns Exception that is instance of System.ArithmeticException

source

pub fn array_type_mismatch() -> Self

Returns Exception that is instance of System.ArrayTypeMismatchException

source

pub fn bad_image_format(msg: &str) -> Self

Returns Exception that is instance of System.BadImageFormatException

source

pub fn cannot_unload_appdomain(msg: &str) -> Self

Returns Exception that is instance of System.CannotUnloadAppdomain

source

pub fn domain_unloaded() -> Self

Returns Exception that is instance of System.AppDomainUnloadedException

source

pub fn divide_by_zero() -> Self

Returns Exception that is instance of System.DivideByZeroException

source

pub fn execution_engine_exception(msg: &str) -> Self

Returns Exception that is instance of System.ExecutionEngineException

source

pub fn file_not_found(fname: &str) -> Self

Returns Exception that is instance of System.IO.FileNotFoundException

source

pub fn index_out_of_range() -> Self

Returns Exception that is instance of System.IndexOutOfRangeException

source

pub fn invald_cast() -> Self

Returns Exception that is instance of System.InvalidCastException

source

pub fn io_exception(msg: &str) -> Self

Returns Exception that is instance of System.IO.IOException

source

pub fn missing_method(class_name: &str, member_name: &str) -> Self

Returns Exception that is instance of System.MissingMethodException

source

pub fn null_reference() -> Self

Returns Exception that is instance of System.NullReferenceException

source

pub fn overflow() -> Self

Returns Exception that is instance of System.OverflowException

source

pub fn security() -> Self

Returns Exception that is instance of System.Security.SecurityException

source

pub fn serialization_exception(msg: &str) -> Self

Returns Exception that is instance of System.Runtime.Serialization.SerializationException

source

pub fn stack_overflow() -> Self

Returns Exception that is instance of System.StackOverflowException

source

pub fn synchronization_lock(msg: &str) -> Self

Returns Exception that is instance of System.SynchronizationLockException

source

pub fn thread_abort() -> Self

Returns Exception that is instance of System.Threading.ThreadAbortException

source

pub fn thread_sate(msg: &str) -> Self

Returns Exception that is instance of System.Threading.ThreadStateException

source

pub fn type_initialization(type_name: &str, inner: &Self) -> Self

Returns Exception that is instance of System.TypeInitializationException with type_name and inner exception inner.

source

pub fn type_load(class_name: &str, member_name: &str) -> Self

Returns Exception that is instance of System.TypeLoadException

source

pub fn invalid_operation(msg: &str) -> Self

Returns Exception that is instance of System.InvalidOperationException

source

pub fn missing_field(class_name: &str, member_name: &str) -> Self

Returns Exception that is instance of System.MissingFieldException

source

pub fn not_supported(msg: &str) -> Self

Returns Exception that is instance of System.NotSupportedException

source

pub fn field_access() -> Self

Returns Exception that is instance of System.FieldAccessException

source

pub fn method_access() -> Self

Returns Exception that is instance of System.MethodAccessException

source

pub fn out_of_memory() -> Self

Returns Exception that is instance of System.OutOfMemoryException

source

pub fn wrapped(inner: &Self) -> Self

Creates Exception with a wraped inner Exception inner.

Trait Implementations§

source§

impl Clone for Exception

source§

fn clone(&self) -> Self

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 Exception

source§

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

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

impl Display for Exception

source§

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

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

impl InteropClass for Exception

source§

impl ObjectTrait for Exception

source§

unsafe fn from_ptr_unchecked(exc_ptr: *mut MonoObject) -> Self

Creates new instance of Self from *mut [MonoObject]. Pointer is guaranteed to be not null, and of type which can be assigned to managed type represented by Self. Read more
source§

fn get_ptr(&self) -> *mut MonoObject

Gets the internal [MonoObject] pointer.
source§

fn cast<Target: ObjectTrait>(&self) -> Option<Target>

source§

unsafe fn from_ptr(obj_ptr: *mut MonoObject) -> Option<Self>

Creates new instance of Self from *mut [MonoObject]. Returns None if either obj_ptr is null OR object obj_ptr points to is of a type which does not derive from the managed type Self represents. Read more
source§

fn hash(&self) -> i32

get hash of this object: This hash is not based on values of objects fields, and differs from result of calling object.GetHash() Read more
source§

fn get_domain(&self) -> Domain

get Domain this object exists in. Read more
source§

fn get_size(&self) -> u32

get size of managed object referenced by self in bytes. Does include builtin hidden data. Read more
source§

fn get_class(&self) -> Class

Returns Class of this object. NOTE: This is function returns the class of the underlying object, not class represented by Self. This means that class returned from get_class may be a class derived from class Self represents. Read more
source§

fn to_mstring(&self) -> Result<Option<MString>, Exception>

Returns result of calling ToString on this Object. Read more
source§

impl<O: ObjectTrait> PartialEq<O> for Exception

source§

fn eq(&self, other: &O) -> 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.

Auto Trait Implementations§

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> InteropRecive for Twhere T: ObjectTrait,

§

type SourceType = *mut _MonoObject

Souce type used by MonoRuntime when calling functions exposed by add_internal_call, or getting a value back from a method, that can be converted to a rust type.
source§

fn get_rust_rep(src: <T as InteropRecive>::SourceType) -> T

Function converting Self::SourceType to type implementing InteropRecive trait.
source§

impl<T> InteropSend for Twhere T: ObjectTrait,

§

type TargetType = *mut _MonoObject

Type used by MonoRuntime, that type implementing InteropSend trait should be converted to when returning it to MonoRuntime.
source§

fn get_mono_rep(src: T) -> <T as InteropSend>::TargetType

Function converting type implementing InteropRecive trait to type that should be returned to MonoRuntime.
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> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. 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.