pub struct NativeArguments { /* private fields */ }
Expand description
Native arguments passed to a standard dart native extension function.
Manages arguments going in, and also return values going out.
Implementations§
Source§impl NativeArguments
impl NativeArguments
Sourcepub unsafe fn new(args: Dart_NativeArguments) -> Self
pub unsafe fn new(args: Dart_NativeArguments) -> Self
Creates a new NativeArguments
from a value given by
the VM.
§Safety
args
must be a pointer to a valid instance of Dart_NativeArguments
.
Not doing so will cause UB as the VM tries to dereference the pointer.
Sourcepub fn get_native_arguments(
&self,
) -> Result<(Vec<Dart_NativeArgument_Descriptor>, Vec<Dart_NativeArgument_Value>), Error>
pub fn get_native_arguments( &self, ) -> Result<(Vec<Dart_NativeArgument_Descriptor>, Vec<Dart_NativeArgument_Value>), Error>
Extracts the native arguments of the function call. This will return
both the type and value of each argument. The two returned Vec
s should
theoretically have the same length.
Sourcepub fn get_native_argument_count(&self) -> usize
pub fn get_native_argument_count(&self) -> usize
Acquires the number of arguments in the NativeArguments
.
Sourcepub fn get_native_argument(&self, idx: usize) -> UnverifiedDartHandle
pub fn get_native_argument(&self, idx: usize) -> UnverifiedDartHandle
Acquires a single argument by instance in the NativeArguments
.
This may be an error handle. It is your job to reassure that it
isn’t by calling .get_error()
.
Sourcepub fn get_string_arg(&self, idx: usize) -> Result<String, Error>
pub fn get_string_arg(&self, idx: usize) -> Result<String, Error>
Attempts to retrieve a string from the argument list, returning an error should it not be a string.
Sourcepub fn get_bool_arg(&self, idx: usize) -> Result<bool, Error>
pub fn get_bool_arg(&self, idx: usize) -> Result<bool, Error>
Attempts to retrieve a boolean from the argument list, returning an error should it not be a boolean.
Sourcepub fn get_i64_arg(&self, idx: usize) -> Result<i64, Error>
pub fn get_i64_arg(&self, idx: usize) -> Result<i64, Error>
Attempts to get a 64 bit signed integer from the argument list, returning an error should it not be an integer.
Sourcepub fn get_f64_arg(&self, idx: usize) -> Result<f64, Error>
pub fn get_f64_arg(&self, idx: usize) -> Result<f64, Error>
Attempts to get a 64 bit floating point value from the argument
list, returning an error should it not be an f64
.
Sourcepub fn set_return(&self, val: UnverifiedDartHandle)
pub fn set_return(&self, val: UnverifiedDartHandle)
Sets an instance as the return value. This (and associated
set_*_return
functions) will be what is received on the
dart end after calling the function.
Sourcepub fn set_bool_return(&self, val: bool)
pub fn set_bool_return(&self, val: bool)
Sets a boolean return value. See set_return
for more information.
Sourcepub fn set_i64_return(&self, val: i64)
pub fn set_i64_return(&self, val: i64)
Sets an integer return value. See set_return
for more information.
Sourcepub fn set_f64_return(&self, val: f64)
pub fn set_f64_return(&self, val: f64)
Sets a floating point return value. See
set_return
for more information.