Skip to main content

SafeFn

Trait SafeFn 

Source
pub trait SafeFn {
    type RawFn;

    // Required methods
    unsafe fn from_raw(raw: Self::RawFn) -> Self;
    fn to_raw(self) -> Self::RawFn;
}
Expand description

Auxiliary conversion methods for CFunction and Hook.

(CFunction and Hook are simple type definitions, so methods can’t be implemented directly…)

Required Associated Types§

Source

type RawFn

The raw version of this function type.

Required Methods§

Source

unsafe fn from_raw(raw: Self::RawFn) -> Self

Converts the given raw function into their safe version.

§Safety

raw must always be safe to call.

Source

fn to_raw(self) -> Self::RawFn

Converts this function into their raw version.

The returned function is safe to call as long as the function receives valid pointers for any pointer argument it may have.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl SafeFn for CFunction

Source§

type RawFn = unsafe extern "C-unwind" fn(*mut lua_State) -> i32

Source§

impl SafeFn for Hook

Source§

type RawFn = unsafe extern "C-unwind" fn(*mut lua_State, *mut lua_Debug)