pub type ErrorClusterPtr<'a> = UPtr<ErrorCluster<'a>>;
Expand description
The pointer as passed by LabVIEW when using “Handles By Value” for type.
Debugging shows only one level of indirection hence UPtr here.
It is recommended to manually call ErrorClusterPtr::as_ref
or ErrorClusterPtr::as_mut
so that null pointers can be detected.
Many string manipulation functions are only available with the link
feature enabled so
it can manipulate LabVIEW Strings.
Aliased Type§
pub struct ErrorClusterPtr<'a>(/* private fields */);
Implementations§
Source§impl ErrorClusterPtr<'_>
impl ErrorClusterPtr<'_>
Sourcepub fn wrap_function<R, E: ToLvError, F: FnOnce() -> Result<R, E>>(
&mut self,
return_on_error: R,
function: F,
) -> R
pub fn wrap_function<R, E: ToLvError, F: FnOnce() -> Result<R, E>>( &mut self, return_on_error: R, function: F, ) -> R
Wrap the provided function in error handling to match LabVIEW semantics.
i.e. no execution on error in, convert return errors into error cluster.
§Parameters
return_on_error
- The value to return if an error.function
- The function to wrap. This is intended to be a closure for easy use.
§Example
use labview_interop::types::ErrorClusterPtr;
use labview_interop::errors::LVInteropError;
use labview_interop::types::LStrHandle;
#[no_mangle]
pub extern "C" fn example_function(mut error_cluster: ErrorClusterPtr, mut string_input: LStrHandle) -> i32 {
error_cluster.wrap_function(42, || -> Result<i32, LVInteropError> {
// Do some work
string_input.set_str("Hello World")?;
Ok(42)
})
}
Sourcepub fn wrap_return_status<E: ToLvError, F: FnOnce() -> Result<(), E>>(
&mut self,
function: F,
) -> LVStatusCode
pub fn wrap_return_status<E: ToLvError, F: FnOnce() -> Result<(), E>>( &mut self, function: F, ) -> LVStatusCode
Wrap the provided function in error handling to match LabVIEW semantics.
i.e. no execution on error in, convert return errors into error cluster.
This version returns the LabVIEW status code of the error.
To return a different value, see ErrorClusterPtr::wrap_function
.
§Parameters
function
- The function to wrap. This is intended to be a closure for easy use.
§Example
use labview_interop::types::{ErrorClusterPtr, LVStatusCode};
use labview_interop::errors::LVInteropError;
use labview_interop::types::LStrHandle;
#[no_mangle]
pub extern "C" fn example_function(mut error_cluster: ErrorClusterPtr, mut string_input: LStrHandle) -> LVStatusCode {
error_cluster.wrap_return_status(|| -> Result<(), LVInteropError> {
// Do some work
string_input.set_str("Hello World")?;
Ok(())
})
}