Skip to main content

hurray_tensor_abi_version

Function hurray_tensor_abi_version 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn hurray_tensor_abi_version( handle: *const HurrayTensor, out: *mut u32, ) -> HurrayStatus
Expand description

Reads the ABI version recorded by the producing build.

Call this first. It is the one accessor guaranteed to work on a tensor produced by any version of this ABI, and every other accessor assumes a caller that has already compared this value against its own HURRAY_C_ABI_VERSION and found it equal (ADR-043 § 5). That ordering is what lets later versions add accessors without breaking consumers compiled against an earlier header.

A tensor from a stream or file read reports this library’s version; one from hurray_tensor_new reports what its producer passed.

§Safety

handle and out MUST be valid, non-null pointers.

§Examples

use hurray_ffi::tensor::{
    hurray_tensor_abi_version, hurray_tensor_destroy, hurray_tensor_new,
};
use hurray_ffi::{
    hurray_buffer_list_new, HurrayBufferList, HurrayTensor, HURRAY_C_ABI_VERSION, HURRAY_OK,
};
let mut version: u32 = 0;
assert_eq!(
    unsafe { hurray_tensor_abi_version(tensor, &mut version) },
    HURRAY_OK,
);
if version != HURRAY_C_ABI_VERSION {
    // Producer and consumer disagree — refuse rather than dereference further.
    return Ok(());
}