pub struct GuestFunctionDefinition<F: Copy> {
pub function_name: String,
pub parameter_types: Vec<ParameterType>,
pub return_type: ReturnType,
pub function_pointer: F,
}Expand description
The definition of a function exposed from the guest to the host.
The type parameter F is the function pointer type. For Rust guests this
is GuestFunc; the C API uses its own CGuestFunc type.
Fields§
§function_name: StringThe function name
parameter_types: Vec<ParameterType>The type of the parameter values for the host function call.
return_type: ReturnTypeThe type of the return value from the host function call
function_pointer: FThe function pointer to the guest function.
Implementations§
Source§impl<F: Copy> GuestFunctionDefinition<F>
impl<F: Copy> GuestFunctionDefinition<F>
Sourcepub fn new(
function_name: String,
parameter_types: Vec<ParameterType>,
return_type: ReturnType,
function_pointer: F,
) -> Self
pub fn new( function_name: String, parameter_types: Vec<ParameterType>, return_type: ReturnType, function_pointer: F, ) -> Self
Create a new GuestFunctionDefinition.
Sourcepub fn from_fn<Output, Args>(
function_name: String,
function: impl AsGuestFunctionDefinition<Output, Args>,
) -> GuestFunctionDefinition<GuestFunc>where
Args: ParameterTuple,
Output: SupportedReturnType,
pub fn from_fn<Output, Args>(
function_name: String,
function: impl AsGuestFunctionDefinition<Output, Args>,
) -> GuestFunctionDefinition<GuestFunc>where
Args: ParameterTuple,
Output: SupportedReturnType,
Create a new GuestFunctionDefinition<GuestFunc> from a function that
implements AsGuestFunctionDefinition.
Sourcepub fn verify_parameters(&self, parameter_types: &[ParameterType]) -> Result<()>
pub fn verify_parameters(&self, parameter_types: &[ParameterType]) -> Result<()>
Verify that self has same signature as the provided parameter_types.
Trait Implementations§
Source§impl<F: Clone + Copy> Clone for GuestFunctionDefinition<F>
impl<F: Clone + Copy> Clone for GuestFunctionDefinition<F>
Source§fn clone(&self) -> GuestFunctionDefinition<F>
fn clone(&self) -> GuestFunctionDefinition<F>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl<F> Freeze for GuestFunctionDefinition<F>where
F: Freeze,
impl<F> RefUnwindSafe for GuestFunctionDefinition<F>where
F: RefUnwindSafe,
impl<F> Send for GuestFunctionDefinition<F>where
F: Send,
impl<F> Sync for GuestFunctionDefinition<F>where
F: Sync,
impl<F> Unpin for GuestFunctionDefinition<F>where
F: Unpin,
impl<F> UnsafeUnpin for GuestFunctionDefinition<F>where
F: UnsafeUnpin,
impl<F> UnwindSafe for GuestFunctionDefinition<F>where
F: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more