pxl_rust/function.rs
1//! Represents a single function within a device kernel.
2//!
3//! User can create `Function` objects that correspond to individual device-side kernels.
4//! Each function can be executed with a set of arguments, which are passed from the host to the device.
5//!
6//! This module provides a Rust abstraction around the C++ `pxl::Function` class.
7
8use crate::ffi;
9
10/// Binding for `Function` object in PXL C++ library.
11/// This struct wraps the FFI object and provides methods for Rust.
12pub struct Function {
13 /// Pointer to the underlying FFI `Function` object.
14 inner: *mut ffi::Function,
15}
16
17/// Implementation of the `Function` struct.
18impl Function {
19 /// Creates a new `Function` wrapper from a raw FFI pointer.
20 /// # Arguments
21 /// * `function_ptr` - A raw pointer to the underlying FFI `Function` object.
22 /// # Safety
23 /// Caller must ensure that `function_ptr` is valid and remains valid for the lifetime of `Function`.
24 pub fn new(function_ptr: *mut ffi::Function) -> Self {
25 Function {
26 inner: function_ptr,
27 }
28 }
29
30 /// Returns a raw pointer to the underlying FFI `Function` object.
31 /// This is called in runtime wrapper APIs requiring a raw pointer.
32 /// # Safety
33 /// Caller must ensure that FFI object is valid.
34 pub fn get(&self) -> *mut ffi::Function {
35 self.inner
36 }
37}