Skip to main content

Module ffi

Module ffi 

Source
Expand description

FFI (Foreign Function Interface) bindings for C/C++ integration.

This module provides C-compatible bindings for embeddenator core types. All functions are marked unsafe and require careful memory management.

§Safety Considerations

  • All pointers must be valid and properly aligned
  • String pointers must be null-terminated UTF-8
  • Caller is responsible for freeing memory allocated by FFI functions
  • No Rust objects should be accessed after being freed

§Example (C)

#include "embeddenator_interop.h"

// Create a vector
SparseVecHandle* vec = sparse_vec_new();

// Use the vector...

// Free the vector
sparse_vec_free(vec);

Structs§

ByteBuffer
Result buffer for returning data to C
SparseVecHandle
Opaque handle to a SparseVec
VSAConfigHandle
Opaque handle to a ReversibleVSAConfig

Functions§

byte_buffer_free
Free a ByteBuffer returned by FFI functions
embeddenator_last_error
Get the last error message (if any)
sparse_vec_bind
Bind two SparseVecs
sparse_vec_bundle
Bundle two SparseVecs
sparse_vec_cosine
Compute cosine similarity between two SparseVecs
sparse_vec_free
Free a SparseVec
sparse_vec_from_json
Deserialize a SparseVec from JSON
sparse_vec_new
Create a new SparseVec
sparse_vec_to_json
Serialize a SparseVec to JSON
vsa_config_free
Free a VSAConfig
vsa_config_new
Create a new default ReversibleVSAConfig
vsa_config_new_custom
Create a new ReversibleVSAConfig with custom parameters
vsa_decode_data
Decode a SparseVec back to data
vsa_encode_data
Encode data into a SparseVec