Safe rust interface
Resolves #19 (closed).
What's done so far:
- Implemented a thread-safe
HerculesImmBox
which provides a standard interface for creating inputs to Hercules functions and handling their outputs in a safe manner. - Using
HerculesImmBox
in cava and edge detection, which significantly cleaned up the code - Implemented a
HerculesMutBox
which provides a standard interface but for mutable references. Not actually sure whether this is ever needed.
ToDo:
- I think we should generate a safer function for the runner which accepts as inputs
HerculesImmBux
/HerculesMutBox
and returns the same, since these boxes are typed and so it improves type-safety (it also removes most the remaining weirdness of the interface, specifically the.to()
)
Merge request reports
Activity
requested review from @rarbore2
assigned to @aaronjc4
- Resolved by rarbore2
Generating the runner interface is necessary rather than a generic wrapper, unfortunately. I'll do that on this branch soon.
- Resolved by rarbore2
Just pushed an example of what I think the safer interface should look like. I think ideally this safer interface would be the actual
.run(...)
method on runner, but we could keep the current version exposed maybe as.unsafe_run()
or something like that.
added 1 commit
- 9cc3faa7 - Improve HerculesMutBox. Edge detection safe interface issues
added 7 commits
-
401d1574...16d655ac - 6 commits from branch
main
- 81240527 - Merge branch 'main' into safe-rust-interface
-
401d1574...16d655ac - 6 commits from branch
- Resolved by rarbore2
added 12 commits
-
5dbb02ca...9b3bb526 - 4 commits from branch
main
- 70b71cfe - First attempt at new HerculesBox
- c076928b - Fix HerculesBox
- 4694aae1 - Fix immutable boxes and make them thread safe
- 71adbd48 - Add HerculesMutBox
- 573d79f9 - Add example of safe runner interface
- 3693e9c9 - Improve HerculesMutBox. Edge detection safe interface issues
- 81525f53 - Fixing lifetime issues
- 255898ca - Actually fixed this time
Toggle commit list-
5dbb02ca...9b3bb526 - 4 commits from branch
added 1 commit
- 27ce61d0 - Clarifying comment regarding run() lifetimes
- Resolved by rarbore2
added 5 commits
-
27ce61d0...5ae86850 - 4 commits from branch
main
- 4cb853f6 - Merge branch 'main' into safe-rust-interface
-
27ce61d0...5ae86850 - 4 commits from branch
added 1 commit
- 3b1f9e24 - Be more precise about lifetimes in RT backend
added 1 commit
- d78c63c3 - edge detection no longer needs longer than lifetime annotations
added 1 commit
- 3d6432d7 - edge detection no longer needs longer than lifetime annotations
So, I'm actually going to merge this in without auto-generating an interface in the RT backend. This is because HerculesBox currently only works for arrays of primitives - it doesn't support Hercules product or summation types. So, we can't auto-generate a safe interface using HerculesBox for all possible Hercules functions. That being said, the
safe_run
used in cava and edge detection is pretty easy to write, so I think this is fine (since we've addressed the main problem of needing device specific code in cava and edge detection)?Edited by rarbore2