Struct wrapped_mono::Exception
source · pub struct Exception { /* private fields */ }
Expand description
Safe representation of MonoException
.
Implementations§
source§impl Exception
impl Exception
sourcepub unsafe fn raise(&self) -> !
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()};
}
sourcepub fn from_name_domain(
domain: &Domain,
image: Image,
namespace: &str,
name: &str
) -> Option<Self>
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’
sourcepub fn from_name(image: Image, namespace: &str, name: &str) -> Option<Self>
pub fn from_name(image: Image, namespace: &str, name: &str) -> Option<Self>
Creates Exception
of type name in namespace from image
sourcepub fn from_name_msg(
image: Image,
namespace: &str,
name: &str,
msg: &str
) -> Option<Self>
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.
sourcepub fn argument_exception(arg: &str, msg: &str) -> Self
pub fn argument_exception(arg: &str, msg: &str) -> Self
Returns Exception
that is instance of System.ArgumentException
sourcepub fn not_implemented(msg: &str) -> Self
pub fn not_implemented(msg: &str) -> Self
Returns Exception
that is instance of System.NotImplementedException
sourcepub fn argument_null(msg: &str) -> Self
pub fn argument_null(msg: &str) -> Self
Returns Exception
that is instance of System.ArgumentNullException
sourcepub fn argument_out_of_range(msg: &str) -> Self
pub fn argument_out_of_range(msg: &str) -> Self
Returns Exception
that is instance of System.ArgumentOutOfRangeException
sourcepub fn arithmetic() -> Self
pub fn arithmetic() -> Self
Returns Exception
that is instance of System.ArithmeticException
sourcepub fn array_type_mismatch() -> Self
pub fn array_type_mismatch() -> Self
Returns Exception
that is instance of System.ArrayTypeMismatchException
sourcepub fn bad_image_format(msg: &str) -> Self
pub fn bad_image_format(msg: &str) -> Self
Returns Exception
that is instance of System.BadImageFormatException
sourcepub fn cannot_unload_appdomain(msg: &str) -> Self
pub fn cannot_unload_appdomain(msg: &str) -> Self
Returns Exception
that is instance of System.CannotUnloadAppdomain
sourcepub fn domain_unloaded() -> Self
pub fn domain_unloaded() -> Self
Returns Exception
that is instance of System.AppDomainUnloadedException
sourcepub fn divide_by_zero() -> Self
pub fn divide_by_zero() -> Self
Returns Exception
that is instance of System.DivideByZeroException
sourcepub fn execution_engine_exception(msg: &str) -> Self
pub fn execution_engine_exception(msg: &str) -> Self
Returns Exception
that is instance of System.ExecutionEngineException
sourcepub fn file_not_found(fname: &str) -> Self
pub fn file_not_found(fname: &str) -> Self
Returns Exception
that is instance of System.IO.FileNotFoundException
sourcepub fn index_out_of_range() -> Self
pub fn index_out_of_range() -> Self
Returns Exception
that is instance of System.IndexOutOfRangeException
sourcepub fn invald_cast() -> Self
pub fn invald_cast() -> Self
Returns Exception
that is instance of System.InvalidCastException
sourcepub fn io_exception(msg: &str) -> Self
pub fn io_exception(msg: &str) -> Self
Returns Exception
that is instance of System.IO.IOException
sourcepub fn missing_method(class_name: &str, member_name: &str) -> Self
pub fn missing_method(class_name: &str, member_name: &str) -> Self
Returns Exception
that is instance of System.MissingMethodException
sourcepub fn null_reference() -> Self
pub fn null_reference() -> Self
Returns Exception
that is instance of System.NullReferenceException
sourcepub fn security() -> Self
pub fn security() -> Self
Returns Exception
that is instance of System.Security.SecurityException
sourcepub fn serialization_exception(msg: &str) -> Self
pub fn serialization_exception(msg: &str) -> Self
Returns Exception
that is instance of System.Runtime.Serialization.SerializationException
sourcepub fn stack_overflow() -> Self
pub fn stack_overflow() -> Self
Returns Exception
that is instance of System.StackOverflowException
sourcepub fn synchronization_lock(msg: &str) -> Self
pub fn synchronization_lock(msg: &str) -> Self
Returns Exception
that is instance of System.SynchronizationLockException
sourcepub fn thread_abort() -> Self
pub fn thread_abort() -> Self
Returns Exception
that is instance of System.Threading.ThreadAbortException
sourcepub fn thread_sate(msg: &str) -> Self
pub fn thread_sate(msg: &str) -> Self
Returns Exception
that is instance of System.Threading.ThreadStateException
sourcepub fn type_initialization(type_name: &str, inner: &Self) -> Self
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
.
sourcepub fn type_load(class_name: &str, member_name: &str) -> Self
pub fn type_load(class_name: &str, member_name: &str) -> Self
Returns Exception
that is instance of System.TypeLoadException
sourcepub fn invalid_operation(msg: &str) -> Self
pub fn invalid_operation(msg: &str) -> Self
Returns Exception
that is instance of System.InvalidOperationException
sourcepub fn missing_field(class_name: &str, member_name: &str) -> Self
pub fn missing_field(class_name: &str, member_name: &str) -> Self
Returns Exception
that is instance of System.MissingFieldException
sourcepub fn not_supported(msg: &str) -> Self
pub fn not_supported(msg: &str) -> Self
Returns Exception
that is instance of System.NotSupportedException
sourcepub fn field_access() -> Self
pub fn field_access() -> Self
Returns Exception
that is instance of System.FieldAccessException
sourcepub fn method_access() -> Self
pub fn method_access() -> Self
Returns Exception
that is instance of System.MethodAccessException
sourcepub fn out_of_memory() -> Self
pub fn out_of_memory() -> Self
Returns Exception
that is instance of System.OutOfMemoryException
Trait Implementations§
source§impl InteropClass for Exception
impl InteropClass for Exception
fn get_mono_class() -> Class
source§impl ObjectTrait for Exception
impl ObjectTrait for Exception
source§unsafe fn from_ptr_unchecked(exc_ptr: *mut MonoObject) -> Self
unsafe fn from_ptr_unchecked(exc_ptr: *mut MonoObject) -> Self
fn cast<Target: ObjectTrait>(&self) -> Option<Target>
source§fn hash(&self) -> i32
fn hash(&self) -> i32
source§fn get_size(&self) -> u32
fn get_size(&self) -> u32
source§impl<O: ObjectTrait> PartialEq<O> for Exception
impl<O: ObjectTrait> PartialEq<O> for Exception
Auto Trait Implementations§
impl RefUnwindSafe for Exception
impl Send for Exception
impl Sync for Exception
impl Unpin for Exception
impl UnwindSafe for Exception
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> InteropRecive for Twhere
T: ObjectTrait,
impl<T> InteropRecive for Twhere T: ObjectTrait,
§type SourceType = *mut _MonoObject
type SourceType = *mut _MonoObject
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
fn get_rust_rep(src: <T as InteropRecive>::SourceType) -> T
Self::SourceType
to type implementing InteropRecive
trait.source§impl<T> InteropSend for Twhere
T: ObjectTrait,
impl<T> InteropSend for Twhere T: ObjectTrait,
§type TargetType = *mut _MonoObject
type TargetType = *mut _MonoObject
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
fn get_mono_rep(src: T) -> <T as InteropSend>::TargetType
InteropRecive
trait to type that should be returned to MonoRuntime
.