rust-spice
WOW! The complete NASA/NAIF Spice toolkit is actually usable on Rust
Intro | Requirements | In action | In development | Usage | License
Intro
SPICE is An Observation Geometry System for Space Science Missions. Visit their website.
Requirements
- Install CSPICE library for your platform.
- In your folder
/path/to/cspice/lib
, rename the static libraries to match standards:cspice.a
->libcspice.a
csupport.a
->libcsupport.a
- Tell Cargo where to look for the CSPICE library. This is done by adding some
lines to
$HOME/.cargo/config.toml
. If the file doesn't exist, create it (read Configuration doc). You need to write:
[]
= ["cspice"]
= ["/path/to/cspice/lib"]
= ["-I/path/to/cspice/include"]
replace YOUR_PLATFORM
by either:
- for linux:
x86_64-unknown-linux-gnu
- for mac:
x86_64-apple-darwin
- for windows:
x86_64-pc-windows-msvc
and replace /path/to/cspice
with the absolute path to your CSPICE installation.
Usage
Add the dependency rust-spice to your Cargo.toml
:
...
[]
= "*" # replace * by the latest version of the crate
In action
A nice and idiomatic interface to Spice,
use spice;
let mut kernel = furnsh;
let et = str2et;
let = spkpos;
// position -> 18.62640405424448, 21.054373008357004, -7.136291402940499
// light time -> 0.00009674257074746383
unload;
You can look for some inspirations in the tests.
In development
Developing an idiomatic interface for Spice in Rust takes time, and not all functions are implemented yet. In the documentation online, a complete guide details which functions are available. If yours is not, you can always use the unsafe API which contains all cspice functions.
For instance, with the unsafe API, the example above would be,
use spice;
use CString;
unsafe
Much less friendly.. yet it is available. I would love some help in order to complete the idiomatic development. You can raise an issue or propose a pull request for the implementation of a specific function.
License
Licensed under the Apache License, Version 2.0.