Skip to content

feat(larod): Add safe Rust bindings - #230

Open
vsem-azamat wants to merge 1 commit into
AxisCommunications:mainfrom
vsem-azamat:feature/larod-completion
Open

vsem-azamat wants to merge 1 commit into
AxisCommunications:mainfrom
vsem-azamat:feature/larod-completion

Conversation

@vsem-azamat

@vsem-azamat vsem-azamat commented Mar 11, 2026

Copy link
Copy Markdown
Contributor

Safe Rust wrapper for the larod C API

Adds a new larod crate with safe Rust bindings around the larod C API. The wrapper covers connection management, device enumeration, model loading/retrieval, tensor allocation, job requests, parameter maps, and error handling.

Review focus

  • FFI ownership and cleanup paths for larod-managed pointers.
  • Safe API boundaries for tensors, jobs, maps, and file-descriptor access.
  • Error handling for null pointers, larod error objects, and fd sentinel values.
  • Consistency with lessons from PR feat(vdo): Add safe Rust bindings for VDO API #223: fallible constructors, explicit unsafe contracts, no safe fd lifetime overclaims, and focused tests/docs.

Current status

  • Rebased onto current main (ACAP Native SDK 12.11.0, armv7hf support).
  • History squashed to one feature commit.
  • Since larod is documented as not thread safe, every FFI call goes through one process-wide lock and all handle types are !Send + !Sync (compile-fail doctests). Feedback on this trade-off is welcome: JobRequest::run holds the lock for the duration of inference.
  • Tensor fd getters return Result<c_int>; larod has no "unset fd" sentinel, only LAROD_INVALID_FD on error.
  • Hardware-gated device-tests have not been run on a device yet.

Local verification

  • cargo fmt -p larod -- --check
  • git diff --check
  • cargo test -p larod
  • cargo clippy -p larod --all-targets -- -D warnings
  • RUSTDOCFLAGS="-Dwarnings" cargo doc -p larod --document-private-items --no-deps

Issue ticket number and link

  • N/A

Checklist before requesting a review

  • I have performed a self-review of my own code
  • I have verified that the code builds perfectly fine on my local system
  • I have added tests that prove my fix is effective or that my feature works
  • I have commented my code, particularly in hard-to-understand areas
  • I have verified that my code follows the style already available in the repository
  • I have made corresponding changes to the documentation

@vsem-azamat vsem-azamat changed the title Feature/larod completion feat(larod): Add save Rust bindings Mar 11, 2026
@vsem-azamat vsem-azamat changed the title feat(larod): Add save Rust bindings feat(larod): Add safe Rust bindings Mar 11, 2026
@vsem-azamat
vsem-azamat force-pushed the feature/larod-completion branch 3 times, most recently from 0290b9c to c99f6ae Compare July 5, 2026 13:12
@vsem-azamat
vsem-azamat marked this pull request as ready for review July 6, 2026 10:15
@vsem-azamat
vsem-azamat requested a review from a team as a code owner July 6, 2026 10:15
@vsem-azamat
vsem-azamat marked this pull request as draft July 6, 2026 10:17
@vsem-azamat
vsem-azamat force-pushed the feature/larod-completion branch from c99f6ae to 3c9417c Compare September 3, 2026 19:43
Add a safe wrapper crate for larod-sys covering connections, devices,
models, maps, tensors, job requests, errors, host-safe tests, and
device-gated tests.

Since larod is documented as not thread safe, every FFI call is serialized
through one process-wide lock and all handle types are !Send + !Sync,
enforced by compile-fail doctests. Raw tensor fd access is unsafe with an
explicit ownership contract, and fd allocation uses a closed FdRequirements
type mapping to the documented LAROD_FD_PROP_* flags.
@vsem-azamat
vsem-azamat force-pushed the feature/larod-completion branch from 3c9417c to b4cd333 Compare September 3, 2026 19:43
@vsem-azamat
vsem-azamat marked this pull request as ready for review September 3, 2026 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant