pub trait RamFn {
type Fn;
const MAX: usize;
// Required methods
fn src(&self) -> *const u8;
fn len(&self) -> usize;
fn rom(&self) -> Self::Fn;
unsafe fn install<const N: usize>(&self, dst: *mut [u8; N]) -> Self::Fn;
}Expand description
Required Associated Constants§
Required Associated Types§
Required Methods§
Sourceunsafe fn install<const N: usize>(&self, dst: *mut [u8; N]) -> Self::Fn
unsafe fn install<const N: usize>(&self, dst: *mut [u8; N]) -> Self::Fn
Copy the code into dst and return the RAM copy as a callable pointer.
dst is a fixed-size buffer; N >= MAX is checked at compile time, so the
buffer is large enough for any function within its declared max. No
runtime length check is needed.
§Safety
dst must point to executable RAM that stays live and unchanged for as
long as the returned pointer is called.
install also assumes the function fits MAX and is position independent.
Both are verified only by cargo-gb over the linked ROM (see the crate
docs); built another way, install may overflow dst or return a pointer
to code that does not run correctly when relocated.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".