Struct BareFnOnce

Source
pub struct BareFnOnce<B: Copy, F, A: JitAlloc = GlobalJitAlloc> { /* private fields */ }
Expand description

Wrapper around a FnOnce closure which exposes a bare function thunk that can invoke it without additional arguments.

Implementations§

Source§

impl<B: Copy, F, A: JitAlloc> BareFnOnce<B, F, A>

Source

pub fn with_jit_alloc<CC>( cconv: CC, fun: F, jit_alloc: A, ) -> Result<Self, JitAllocError>
where (CC, F): FnOnceThunk<CC, B>,

👎Deprecated since 0.3.0: please use try_new_in instead

Wraps fun, producing a bare function with calling convention cconv.

Uses the provided JIT allocator to allocate the W^X memory used to create the thunk.

Source

pub fn try_new_in<CC>( cconv: CC, fun: F, jit_alloc: A, ) -> Result<Self, JitAllocError>
where (CC, F): FnOnceThunk<CC, B>,

Wraps fun, producing a bare function with calling convention cconv.

Uses the provided JIT allocator to allocate the W^X memory used to create the thunk.

Source

pub fn new_in<CC>(cconv: CC, fun: F, jit_alloc: A) -> Self
where (CC, F): FnOnceThunk<CC, B>,

Wraps fun, producing a bare function with calling convention cconv.

Uses jit_alloc to allocate the W^X memory used to create the thunk.

§Panics

If the provided JIT allocator fails to allocate memory. For a non-panicking version, see try_new_in.

Source

pub fn new_c_in(fun: F, jit_alloc: A) -> Self
where (C, F): FnOnceThunk<C, B>,

Create a bare function thunk using the C calling convention for fun.

The W^X memory required is allocated using the provided JIT allocator.

Source

pub fn new_system_in(fun: F, jit_alloc: A) -> Self
where (System, F): FnOnceThunk<System, B>,

Create a bare function thunk using the system calling convention for fun.

The W^X memory required is allocated using the provided JIT allocator.

Source

pub fn new_sysv64_in(fun: F, jit_alloc: A) -> Self
where (Sysv64, F): FnOnceThunk<Sysv64, B>,

Available on non-Windows and x86-64 only.

Create a bare function thunk using the sysv64 calling convention for fun.

The W^X memory required is allocated using the provided JIT allocator.

Source

pub fn new_aapcs_in(fun: F, jit_alloc: A) -> Self
where (Aapcs, F): FnOnceThunk<Aapcs, B>,

Available on ARM only.

Create a bare function thunk using the aapcs calling convention for fun.

The W^X memory required is allocated using the provided JIT allocator.

Source

pub fn new_fastcall_in(fun: F, jit_alloc: A) -> Self
where (Fastcall, F): FnOnceThunk<Fastcall, B>,

Available on Windows and (x86-64 or x86) only.

Create a bare function thunk using the fastcall calling convention for fun.

The W^X memory required is allocated using the provided JIT allocator.

Source

pub fn new_stdcall_in(fun: F, jit_alloc: A) -> Self
where (Stdcall, F): FnOnceThunk<Stdcall, B>,

Available on Windows and (x86-64 or x86) only.

Create a bare function thunk using the stdcall calling convention for fun.

The W^X memory required is allocated using the provided JIT allocator.

Source

pub fn new_cdecl_in(fun: F, jit_alloc: A) -> Self
where (Cdecl, F): FnOnceThunk<Cdecl, B>,

Available on Windows and (x86-64 or x86) only.

Create a bare function thunk using the cdecl calling convention for fun.

The W^X memory required is allocated using the provided JIT allocator.

Source

pub fn new_thiscall_in(fun: F, jit_alloc: A) -> Self
where (Thiscall, F): FnOnceThunk<Thiscall, B>,

Available on Windows and x86 only.

Create a bare function thunk using the thiscall calling convention for fun.

The W^X memory required is allocated using the provided JIT allocator.

Source

pub fn new_win64_in(fun: F, jit_alloc: A) -> Self
where (Win64, F): FnOnceThunk<Win64, B>,

Available on Windows and x86-64 only.

Create a bare function thunk using the win64 calling convention for fun.

The W^X memory required is allocated using the provided JIT allocator.

Source

pub fn leak(self) -> B
where Self: 'static,

Leak the underlying closure, returning the unsafe bare function pointer that invokes it.

self must be 'static for this method to be called.

§Safety

While this method is safe, the returned function pointer is not. In particular, it must not be called when:

  • The function has been called before.

  • The closure is not Send, if calling from a different thread than the current one.

Source§

impl<B: Copy, F> BareFnOnce<B, F, GlobalJitAlloc>

Source

pub fn new<CC>(cconv: CC, fun: F) -> Self
where (CC, F): FnOnceThunk<CC, B>,

Available on crate feature bundled_jit_alloc only.

Wraps fun, producing a bare function with calling convention cconv.

The W^X memory required is allocated using the global JIT allocator.

Source

pub fn new_c(fun: F) -> Self
where (C, F): FnOnceThunk<C, B>,

Available on crate feature bundled_jit_alloc only.

Create a bare function thunk using the C calling convention for fun.

The W^X memory required is allocated using the global JIT allocator.

Source

pub fn new_system(fun: F) -> Self
where (System, F): FnOnceThunk<System, B>,

Available on crate feature bundled_jit_alloc only.

Create a bare function thunk using the system calling convention for fun.

The W^X memory required is allocated using the global JIT allocator.

Source

pub fn new_sysv64(fun: F) -> Self
where (Sysv64, F): FnOnceThunk<Sysv64, B>,

Available on non-Windows and x86-64 and crate feature bundled_jit_alloc only.

Create a bare function thunk using the sysv64 calling convention for fun.

The W^X memory required is allocated using the global JIT allocator.

Source

pub fn new_aapcs(fun: F) -> Self
where (Aapcs, F): FnOnceThunk<Aapcs, B>,

Available on crate feature bundled_jit_alloc and ARM only.

Create a bare function thunk using the aapcs calling convention for fun.

The W^X memory required is allocated using the global JIT allocator.

Source

pub fn new_fastcall(fun: F) -> Self
where (Fastcall, F): FnOnceThunk<Fastcall, B>,

Available on Windows and (x86-64 or x86) and crate feature bundled_jit_alloc only.

Create a bare function thunk using the fastcall calling convention for fun.

The W^X memory required is allocated using the global JIT allocator.

Source

pub fn new_stdcall(fun: F) -> Self
where (Stdcall, F): FnOnceThunk<Stdcall, B>,

Available on Windows and (x86-64 or x86) and crate feature bundled_jit_alloc only.

Create a bare function thunk using the stdcall calling convention for fun.

The W^X memory required is allocated using the global JIT allocator.

Source

pub fn new_cdecl(fun: F) -> Self
where (Cdecl, F): FnOnceThunk<Cdecl, B>,

Available on Windows and (x86-64 or x86) and crate feature bundled_jit_alloc only.

Create a bare function thunk using the cdecl calling convention for fun.

The W^X memory required is allocated using the global JIT allocator.

Source

pub fn new_thiscall(fun: F) -> Self
where (Thiscall, F): FnOnceThunk<Thiscall, B>,

Available on Windows and x86 and crate feature bundled_jit_alloc only.

Create a bare function thunk using the thiscall calling convention for fun.

The W^X memory required is allocated using the global JIT allocator.

Source

pub fn new_win64(fun: F) -> Self
where (Win64, F): FnOnceThunk<Win64, B>,

Available on Windows and x86-64 and crate feature bundled_jit_alloc only.

Create a bare function thunk using the win64 calling convention for fun.

The W^X memory required is allocated using the global JIT allocator.

Trait Implementations§

Source§

impl<B: Copy, F, A: JitAlloc> Drop for BareFnOnce<B, F, A>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<B: Copy, F: Send, A: JitAlloc + Send> Send for BareFnOnce<B, F, A>

Source§

impl<B: Copy, F: Sync, A: JitAlloc + Sync> Sync for BareFnOnce<B, F, A>

Auto Trait Implementations§

§

impl<B, F, A> Freeze for BareFnOnce<B, F, A>
where A: Freeze,

§

impl<B, F, A> RefUnwindSafe for BareFnOnce<B, F, A>

§

impl<B, F, A> Unpin for BareFnOnce<B, F, A>
where A: Unpin, B: Unpin,

§

impl<B, F, A> UnwindSafe for BareFnOnce<B, F, A>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Source§

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.