pub struct PlatformImpl(/* private fields */);Expand description
Table of pointers to platform abstraction layer functions.
Implementations§
Source§impl PlatformImpl
impl PlatformImpl
Sourcepub fn new(source_filename: Option<&'static CStr>) -> Self
pub fn new(source_filename: Option<&'static CStr>) -> Self
Create a new, empty PlatformImpl.
By default, all function pointers are null, meaning the default implementations will be used.
§Arguments
source_filename- Optional C string representing the source filename the platform implementation is defined in. In case of multiple platform implementations being registered, this can help in debugging. To obtain a&'static CStrfor the current file, you can useCStr::from_bytes_with_nul_unchecked(concat!(file!(), "\0").as_bytes()).
Sourcepub fn set_init<F>(&mut self, f: F)
pub fn set_init<F>(&mut self, f: F)
Set the init function.
The init function initialize the platform abstraction layer. It should be called before any other function provided by the PAL to initialize any global state.
The closure will be passed through FFI and called later by the Cpp ExecuTorch library. The closure must be zero-sized, trivially copyable (and dropped), Send, Sync, and ’static.
§Panics
This function will panic if the provided closure is not zero-sized.
Sourcepub fn set_abort<F>(&mut self, f: F)
pub fn set_abort<F>(&mut self, f: F)
Set the abort function.
The abort function immediately abort execution, setting the device into an error state, if available.
The closure will be passed through FFI and called later by the Cpp ExecuTorch library. The closure must be zero-sized, trivially copyable (and dropped), Send, Sync, and ’static.
§Panics
This function will panic if the provided closure is not zero-sized.
Sourcepub fn set_current_ticks<F>(&mut self, f: F)
pub fn set_current_ticks<F>(&mut self, f: F)
Set the current_ticks function.
The current_ticks function returns a monotonically non-decreasing timestamp in system ticks.
The closure will be passed through FFI and called later by the Cpp ExecuTorch library. The closure must be zero-sized, trivially copyable (and dropped), Send, Sync, and ’static.
§Panics
This function will panic if the provided closure is not zero-sized.
Sourcepub fn set_ticks_to_ns_multiplier<F>(&mut self, f: F)
pub fn set_ticks_to_ns_multiplier<F>(&mut self, f: F)
Set the ticks_to_ns_multiplier function.
The ticks_to_ns_multiplier function returns the conversion rate from system ticks to nanoseconds as a fraction. To convert a system ticks to nanoseconds, multiply the tick count by the numerator and then divide by the denominator:
nanoseconds = ticks * numerator / denominatorThe closure will be passed through FFI and called later by the Cpp ExecuTorch library. The closure must be zero-sized, trivially copyable (and dropped), Send, Sync, and ’static.
§Panics
This function will panic if the provided closure is not zero-sized.
Sourcepub fn set_emit_log_message<F>(&mut self, f: F)
pub fn set_emit_log_message<F>(&mut self, f: F)
Set the emit_log_message function.
The closure will be passed through FFI and called later by the Cpp ExecuTorch library. The closure must be zero-sized, trivially copyable (and dropped), Send, Sync, and ’static.
§Panics
This function will panic if the provided closure is not zero-sized.
Sourcepub fn set_allocate<F>(&mut self, f: F)
pub fn set_allocate<F>(&mut self, f: F)
Set the allocate function.
The allocate function allocates a block of memory of the given size in bytes and returns a pointer to it.
May return None if the allocation fails.
Memory allocated by this function will be freed later by a call to the platform’s free function.
The closure will be passed through FFI and called later by the Cpp ExecuTorch library. The closure must be zero-sized, trivially copyable (and dropped), Send, Sync, and ’static.
§Panics
This function will panic if the provided closure is not zero-sized.
Sourcepub fn set_free<F>(&mut self, f: F)
pub fn set_free<F>(&mut self, f: F)
Set the free function.
The free function frees a block of memory previously allocated by the platform’s allocate function.
The closure will be passed through FFI and called later by the Cpp ExecuTorch library. The closure must be zero-sized, trivially copyable (and dropped), Send, Sync, and ’static.
§Panics
This function will panic if the provided closure is not zero-sized.