OpenPitStringViewNon-owning UTF-8 string view.
This type never owns memory. It borrows bytes from another object.
Lifetime contract:
ptr points to len readable bytes;ptr.typedef struct OpenPitStringView {
const uint8_t * ptr;
size_t len;
} OpenPitStringView;
OpenPitSharedStringOwning shared-string handle.
Use this type when an FFI function needs to hand a string to the caller whose lifetime must extend beyond the single FFI call and whose storage must not depend on thread-local state remaining intact on the reader side.
Ownership contract:
*mut OpenPitSharedString returned through FFI is owned by
the caller;openpit_destroy_shared_string when no
longer needed; failing to do so leaks the underlying allocation;Read contract:
openpit_shared_string_view;OpenPitStringView is valid while this specific handle is
alive and must not outlive the call to openpit_destroy_shared_string for
this handle.Threading contract:
typedef struct OpenPitSharedString OpenPitSharedString;
openpit_destroy_shared_stringReleases a OpenPitSharedString handle.
Null input is a no-op.
After this call, the handle and any OpenPitStringView previously obtained from
it are invalid and must not be used.
void openpit_destroy_shared_string(
OpenPitSharedString * handle
);
openpit_shared_string_viewBorrows a read-only view of the bytes stored in the handle.
Returns an unset view (ptr == null, len == 0) when handle is null.
The returned view is valid only while handle remains alive. The caller must
copy the bytes if they must outlive the handle.
OpenPitStringView openpit_shared_string_view(
const OpenPitSharedString * handle
);