pub trait FnPtr:
PartialEq
+ Eq
+ PartialOrd
+ Ord
+ Hash
+ Pointer
+ Debug
+ Clone
+ Copy
+ Send
+ Sync
+ Unpin
+ UnwindSafe
+ RefUnwindSafe
+ Sized {
type Args;
type Output;
type ArityMarker: Arity;
type SafetyMarker: Safety;
type AbiMarker: Abi;
const ARITY: usize;
const IS_SAFE: bool;
const IS_EXTERN: bool;
const ABI: Abi;
// Required methods
fn as_ptr(&self) -> UntypedFnPtr;
unsafe fn from_ptr(ptr: UntypedFnPtr) -> Self;
// Provided methods
fn addr(&self) -> usize { ... }
unsafe fn from_addr(addr: usize) -> Self { ... }
fn as_unsafe(&self) -> <Self as WithSafety<Unsafe>>::F
where Self: AsUnsafe { ... }
unsafe fn as_safe(&self) -> <Self as WithSafety<Safe>>::F
where Self: AsSafe { ... }
unsafe fn with_abi<Abi: Abi>(&self) -> <Self as WithAbi<Abi>>::F
where Self: WithAbi<Abi> { ... }
unsafe fn with_safety<Safety: Safety>(
&self,
) -> <Self as WithSafety<Safety>>::F
where Self: WithSafety<Safety> { ... }
}Expand description
Marker trait for all function pointers.
Required Associated Constants§
Required Associated Types§
Sourcetype ArityMarker: Arity
type ArityMarker: Arity
Marker type denoting arity
Sourcetype SafetyMarker: Safety
type SafetyMarker: Safety
Marker type denoting safety
Required Methods§
Sourcefn as_ptr(&self) -> UntypedFnPtr
fn as_ptr(&self) -> UntypedFnPtr
Returns a untyped function pointer for this function.
Sourceunsafe fn from_ptr(ptr: UntypedFnPtr) -> Self
unsafe fn from_ptr(ptr: UntypedFnPtr) -> Self
Constructs an instance from an untyped function pointer.
§Safety
The given pointer has to point to a function of the correct type.
Provided Methods§
Sourceunsafe fn from_addr(addr: usize) -> Self
unsafe fn from_addr(addr: usize) -> Self
Constructs an instance from an address.
§Safety
The given pointer has to point to a function of the correct type.
Sourcefn as_unsafe(&self) -> <Self as WithSafety<Unsafe>>::Fwhere
Self: AsUnsafe,
fn as_unsafe(&self) -> <Self as WithSafety<Unsafe>>::Fwhere
Self: AsUnsafe,
Produces an unsafe version of this function pointer.
Sourceunsafe fn as_safe(&self) -> <Self as WithSafety<Safe>>::Fwhere
Self: AsSafe,
unsafe fn as_safe(&self) -> <Self as WithSafety<Safe>>::Fwhere
Self: AsSafe,
Produces a safe version of this function pointer.
§Safety
Caller must ensure the underlying function is actually safe to call.
Sourceunsafe fn with_abi<Abi: Abi>(&self) -> <Self as WithAbi<Abi>>::Fwhere
Self: WithAbi<Abi>,
unsafe fn with_abi<Abi: Abi>(&self) -> <Self as WithAbi<Abi>>::Fwhere
Self: WithAbi<Abi>,
Produces a version of this function pointer with the given ABI.
§Safety
Caller must ensure that the resulting ABI transformation is sound.
Sourceunsafe fn with_safety<Safety: Safety>(&self) -> <Self as WithSafety<Safety>>::Fwhere
Self: WithSafety<Safety>,
unsafe fn with_safety<Safety: Safety>(&self) -> <Self as WithSafety<Safety>>::Fwhere
Self: WithSafety<Safety>,
Produces a version of this function pointer with the given safety.
§Safety
Caller must ensure that this function pointer is safe when casting to a safe function.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.