Skip to main content

MainFunctionAbi

Struct MainFunctionAbi 

Source
#[repr(C)]
pub struct MainFunctionAbi { pub data: usize, pub virtual_table: usize, }
Expand description

Plain-data payload of GET_MAIN_FUNCTION: the two words of a MainFunction fat pointer, so the payload size and layout are unchanged. A function pointer is not plain data, so the payload type is this mirror; the host converts it back where the value is read.

The value carries the owning Box<dyn Fn> pointer, so it is not Clone/Copy: convert it with MainFunctionAbi::into_main_function at most once, or the box would be freed twice.

Fields§

§data: usize§virtual_table: usize

Implementations§

Source§

impl MainFunctionAbi

Source

pub unsafe fn into_main_function(self) -> MainFunction

Reinterprets a payload written by the host device as the function pointer it carries.

The payload holds an owning Box<dyn Fn>, so it must be converted at most once: converting a copy twice would free the box twice.

§Safety

The value must come from a MainFunction produced by the host: arbitrary bytes are not a valid function pointer.

Trait Implementations§

Source§

impl Debug for MainFunctionAbi

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for MainFunctionAbi

Source§

fn default() -> MainFunctionAbi

Returns the “default value” for a type. Read more
Source§

impl From<Option<Box<dyn Fn(&'static ExecutableContext, Standard<'static>, Vec<String>) -> Pin<Box<dyn Future<Output = Result<(), NonZero<usize>>>>>>>> for MainFunctionAbi

Source§

fn from(value: MainFunction) -> Self

Converts to this type from the input type.
Source§

impl PlainData for MainFunctionAbi

Auto Trait Implementations§

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.