Safe Rust bindings to cuJSON — a GPU JSON parser
from the paper cuJSON: A GPU-Accelerated JSON Parser (ASPLOS '26,
cited in the workspace Cargo.toml description). This crate calls the
upstream CUDA kernels through the plain C ABI in
crates/cujson-sys/cuda/cujson_capi.h and exposes the resulting tape
(tape::Tape) through a Document/Node navigator
(crates/cujson/src/tape/document.rs).
The cuda feature
Without it (the default), every parsing function returns
Err(Error::CudaNotCompiled) — the crate still builds and its
navigator/CPU-reference code (cpu-reference feature) still works, but
no FFI declarations exist to call. With it, build.rs
(crates/cujson-sys/build.rs) compiles upstream's CUDA sources with
nvcc and links cudart_static, so the resulting binary depends only
on the NVIDIA driver (libcuda.so.1, loaded at runtime) — no CUDA
shared libraries need to be installed or bundled. CUJSON_CUDA_ARCHS
(an env var read by that build script) overrides the default compiled
architecture list, e.g. CUJSON_CUDA_ARCHS=80 for a fast local build
targeting one GPU generation.
Limits
cuJSON uses int-sized token counts internally. Inputs within 8 bytes
of i32::MAX (see [MAX_INPUT_LEN]) are rejected by this crate with
[Error::InputTooLarge] before ever reaching C++.
Example
# #[cfg(feature = "cuda")]
# fn main() -> Result<(), cujson::Error> {
let doc = cujson::parse(br#"{"a": [1, 2, 3]}"#)?;
let a = doc.root().get("a").unwrap();
assert_eq!(a.index(1).unwrap().as_i64(), Ok(2));
# Ok(())
# }
# #[cfg(not(feature = "cuda"))]
# fn main() {}