pub trait FnPtr:
PartialEq
+ Eq
+ PartialOrd
+ Ord
+ Hash
+ Pointer
+ Debug
+ Clone
+ Copy
+ Send
+ Sync
+ Unpin
+ UnwindSafe
+ RefUnwindSafe
+ Sized
+ WithOutputImpl
+ WithArgsImpl
+ WithSafetyImpl<Safe>
+ WithSafetyImpl<Unsafe>
+ WithAbiImpl<Rust>
+ WithAbiImpl<C>
+ WithAbiImpl<CUnwind>
+ WithAbiImpl<System>
+ WithAbiImpl<SystemUnwind>
+ WithAbiImpl<EfiApi> {
type Args: Tuple;
type Output;
type Safety: Safety;
type Abi: Abi;
const ARITY: usize;
const IS_SAFE: bool;
const IS_EXTERN: bool;
const ABI: AbiValue;
// 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 { ... }
unsafe fn cast<F: FnPtr>(&self) -> F { ... }
fn as_unsafe(&self) -> <Self as WithSafety<Unsafe>>::F { ... }
unsafe fn as_safe(&self) -> <Self as WithSafety<Safe>>::F { ... }
unsafe fn with_safety<Safety: Safety>(
&self,
) -> <Self as WithSafety<Safety>>::F
where Self: WithSafety<Safety> { ... }
unsafe fn with_abi<Abi: Abi>(&self) -> <Self as WithAbi<Abi>>::F
where Self: WithAbi<Abi> { ... }
unsafe fn with_output<Output>(&self) -> <Self as WithOutput<Output>>::F
where Self: WithOutput<Output> { ... }
unsafe fn with_args<Args: Tuple>(&self) -> <Self as WithArgs<Args>>::F
where Self: WithArgs<Args> { ... }
}Expand description
Marker trait for all function pointers.
Required Associated Constants§
Required Associated Types§
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.
Sourceunsafe fn cast<F: FnPtr>(&self) -> F
unsafe fn cast<F: FnPtr>(&self) -> F
Casts this function pointer to a different function pointer type.
§Safety
Caller must ensure that the resulting transformation is sound.
Sourcefn as_unsafe(&self) -> <Self as WithSafety<Unsafe>>::F
fn as_unsafe(&self) -> <Self as WithSafety<Unsafe>>::F
Produces an unsafe version of this function pointer.
Sourceunsafe fn as_safe(&self) -> <Self as WithSafety<Safe>>::F
unsafe fn as_safe(&self) -> <Self as WithSafety<Safe>>::F
Produces a safe version of this function pointer.
§Safety
Caller must ensure the underlying function is actually safe to call.
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.
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_output<Output>(&self) -> <Self as WithOutput<Output>>::Fwhere
Self: WithOutput<Output>,
unsafe fn with_output<Output>(&self) -> <Self as WithOutput<Output>>::Fwhere
Self: WithOutput<Output>,
Produces a version of this function pointer with the given return type.
§Safety
Caller must ensure that the resulting transformation is sound.
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.