| Crates.io | embeddenator-interop |
| lib.rs | embeddenator-interop |
| version | 0.21.0 |
| created_at | 2026-01-09 22:31:32.946046+00 |
| updated_at | 2026-01-25 18:37:10.181324+00 |
| description | Kernel interop and system integration for Embeddenator |
| homepage | |
| repository | https://github.com/tzervas/embeddenator-interop |
| max_upload_size | |
| id | 2033015 |
| size | 147,995 |
Interoperability layer for Embeddenator: format conversions, FFI bindings, and language integrations.
Independent component extracted from the Embeddenator monolithic repository. Part of the Embeddenator workspace.
Repository: https://github.com/tzervas/embeddenator-interop
Phase 2B Component Migration - Core functionality complete.
Implementation includes:
python featurepython feature)compression-zstd feature)compression-lz4 feature)c-bindings feature)include/embeddenator_interop.huse embeddenator_interop::formats::{sparse_vec_to_format, sparse_vec_from_format, OutputFormat};
use embeddenator_vsa::SparseVec;
// Create a vector
let vec = SparseVec {
pos: vec![1, 2, 3],
neg: vec![4, 5],
};
// Convert to JSON
let json_bytes = sparse_vec_to_format(&vec, OutputFormat::JsonPretty).unwrap();
let from_json = sparse_vec_from_format(&json_bytes, OutputFormat::Json).unwrap();
// Convert to bincode
let bincode_bytes = sparse_vec_to_format(&vec, OutputFormat::Bincode).unwrap();
let from_bincode = sparse_vec_from_format(&bincode_bytes, OutputFormat::Bincode).unwrap();
// Debug text format
let text = sparse_vec_to_format(&vec, OutputFormat::Text).unwrap();
println!("{}", String::from_utf8(text).unwrap());
use embeddenator_interop::FileAdapter;
use embeddenator_vsa::{SparseVec, ReversibleVSAConfig};
use embeddenator_fs::Manifest;
// Save and load sparse vectors
let vec = SparseVec::new();
FileAdapter::save_sparse_vec("vector.bin", &vec).unwrap();
let loaded = FileAdapter::load_sparse_vec("vector.bin").unwrap();
// Save and load config
let config = ReversibleVSAConfig::default();
FileAdapter::save_vsa_config("config.json", &config).unwrap();
let loaded_config = FileAdapter::load_vsa_config("config.json").unwrap();
// Save and load manifests
let manifest = Manifest {
files: Vec::new(),
total_chunks: 0,
};
FileAdapter::save_manifest("manifest.json", &manifest).unwrap();
let loaded_manifest = FileAdapter::load_manifest("manifest.json").unwrap();
use embeddenator_interop::BatchAdapter;
use embeddenator_vsa::ReversibleVSAConfig;
let config = ReversibleVSAConfig::default();
let data_chunks = vec![b"hello".as_slice(), b"world".as_slice()];
// Batch encode
let vectors = BatchAdapter::batch_encode(&data_chunks, &config);
// Batch similarity
let query = vectors[0].clone();
let similarities = BatchAdapter::batch_similarity(&query, &vectors);
// Batch bundle
let bundled = BatchAdapter::batch_bundle(&vectors);
#include "embeddenator_interop.h"
// Create vectors
SparseVecHandle* vec1 = sparse_vec_new();
SparseVecHandle* vec2 = sparse_vec_new();
// Perform operations
SparseVecHandle* bundled = sparse_vec_bundle(vec1, vec2);
double similarity = sparse_vec_cosine(vec1, vec2);
// Encode data
VSAConfigHandle* config = vsa_config_new();
const char* data = "Hello, C!";
SparseVecHandle* encoded = vsa_encode_data(config, (const uint8_t*)data, strlen(data), NULL);
// Serialize to JSON
ByteBuffer json = sparse_vec_to_json(encoded);
// Use json.data, json.len...
byte_buffer_free(json);
// Cleanup
sparse_vec_free(vec1);
sparse_vec_free(vec2);
sparse_vec_free(bundled);
sparse_vec_free(encoded);
vsa_config_free(config);
from embeddenator_interop import SparseVec, VSAConfig
# Create vectors
vec1 = SparseVec.from_indices([1, 2, 3], [4, 5])
vec2 = SparseVec.from_indices([2, 3, 4], [5, 6])
# Operations
bundled = vec1.bundle(vec2)
similarity = vec1.cosine(vec2)
# Encode data
config = VSAConfig.new()
data = b"Hello, Python!"
encoded = config.encode(data, None)
# Serialize
json_str = encoded.to_json()
bytes_data = encoded.to_bytes()
Default features: None
Optional features:
python: Enable Python bindings via PyO3c-bindings: Enable automated C header generation with cbindgencompression-zstd: Enable Zstd compression codeccompression-lz4: Enable LZ4 compression codeccompression: Enable all compression codecs (zstd + lz4)[dependencies]
embeddenator-interop = { version = "0.20.0-alpha.1" }
# With Python support
embeddenator-interop = { version = "0.20.0-alpha.1", features = ["python"] }
# Standard build
cargo build --manifest-path embeddenator-interop/Cargo.toml
# With compression support
cargo build --manifest-path embeddenator-interop/Cargo.toml --features compression
# Generate C headers (creates include/embeddenator_interop.h)
cargo build --manifest-path embeddenator-interop/Cargo.toml --features c-bindings
# With all features
cargo build --manifest-path embeddenator-interop/Cargo.toml --all-features
# With Python support
cargo build --manifest-path embeddenator-interop/Cargo.toml --features python
# Release build
cargo build --manifest-path embeddenator-interop/Cargo.toml --release
# Run all tests
cargo test --manifest-path embeddenator-interop/Cargo.toml
# Run with Python tests
cargo test --manifest-path embeddenator-interop/Cargo.toml --features python
| Type | JSON | Bincode | Text |
|---|---|---|---|
| SparseVec | ✓ | ✓ | ✓ (read-only) |
| Engram | ✓ | ✓ | ✓ (read-only) |
| Manifest | ✓ | ✓ | ✓ (read-only) |
| SubEngram | ✓ | ✓ | ✓ (read-only) |
| VSAConfig | ✓ | ✓ | ✓ (read-only) |
All FFI functions are marked unsafe and require:
See FFI documentation for detailed safety contracts.
--features pythonMIT