Crates.io | libswisseph-sys |
lib.rs | libswisseph-sys |
version | 0.1.2 |
source | src |
created_at | 2024-07-27 23:30:14.083317 |
updated_at | 2024-08-10 20:52:08.767954 |
description | Rust system wrapper for swisseph C library |
homepage | |
repository | https://github.com/jgrowl/libswisseph-sys_rs |
max_upload_size | |
id | 1317583 |
size | 15,264,572 |
Rust system wrapper for the swisseph C library
By default, the main pub export will be the raw bindgen generated files. These bindings require the user to know what types the functions expect as many of the functions take pointers to arrays of varying sizes.
use libswisseph_sys::*;
Also included is a tuple_result mod that provides functions where all the return data is created and returned from the function itself. Error codes are also checked and the entire calculation is wrapped in a Result type so rust users can do a standard check for Ok or Err.
use libswisseph_sys::tuple_result::*;
Ephemeris files are excluded from this crate so that it fits on crates.io. There are standard standard ephemeris files located in the swisseph c library and there are many more that can be included depending on the desired calculation. For example: astroids, JPL, etc.
The ephemeris path with default to and can be set as described in the swisseph C library. See https://github.com/aloistr/swisseph/ for further details.
use libswisseph_sys::*;
let mut xx: [f64; 6] = [0.0; 6];
let mut serr = [0; 256];
let y = 2002;
let m = 1;
let d = 1;
let h = 0.0;
let i_flag = SE_GREG_CAL as i32;
let tjd_ut = swe_julday(y, m, d, h, i_flag);
let ipl = SE_SUN as i32;
swe_calc_ut(
tjd_ut,
ipl,
SEFLG_SPEED as i32,
xx.as_mut_ptr(),
serr.as_mut_ptr(),
);
let _lng = xx[0];
let _lat = xx[1];
let _speed = xx[3];
https://www.astro.com/swisseph/swephprg.htm https://www.astro.com/ftp/swisseph/doc/swisseph.pdf
Rustc u128 is not ffi safe. Any functions that reference u128 have been ignored to prevent compilation errors.
git submodule add https://github.com/aloistr/swisseph.git libswisseph/
There is some functionality provided by the Swiss Ephemeris that are not referenced in header files and thus will not be included. Several of the files include main function, for example the swevents does event calculation and outputs to local file.
swedates also has overlapping types that causes errors so it has not been included.