Bytes
OpenPitBytesView
Non-owning byte slice view.
Lifetime contract:
ptrpoints tolenreadable bytes;- the memory is valid while the original object is alive;
- the caller must not free or mutate memory behind
ptr; - if the caller needs to retain the bytes beyond that announced lifetime, the caller must copy them.
typedef struct OpenPitBytesView {
const uint8_t * ptr;
size_t len;
} OpenPitBytesView;
OpenPitSharedBytes
Owning shared-bytes handle.
Use this type when an FFI function needs to hand a binary payload to the caller whose lifetime must extend beyond the single FFI call.
Ownership contract:
- every non-null
*mut OpenPitSharedBytesreturned through FFI is owned by the caller; - the caller MUST release it with
openpit_destroy_shared_byteswhen no longer needed; failing to do so leaks the underlying allocation.
typedef struct OpenPitSharedBytes OpenPitSharedBytes;
openpit_destroy_shared_bytes
Releases a OpenPitSharedBytes handle.
Null input is a no-op.
void openpit_destroy_shared_bytes(
OpenPitSharedBytes * handle
);
openpit_shared_bytes_view
Borrows a read-only view of the bytes stored in the handle.
Returns an unset view (ptr == null, len == 0) when handle is null.
OpenPitBytesView openpit_shared_bytes_view(
const OpenPitSharedBytes * handle
);