Traditional astrology for rust

Rust library by Stéphane Bressani (s.bressani@bluewin.ch)

Using swissephem c library by Astrodienst AG by Dieter Koch and Alois Treindl (https://www.astro.com/ftp/swisseph/)

The source code is released under an CC License, which allows it to be used also on commercial projects. This software uses the swiss ephemeris which is licensed GPL.

Therefore, if you want to use astrocomputeswisseph in your commercial projects, you must adhere to the GPL license or buy a Swiss Ephemeris commercial license.

Use of library

For get the version as a pointer const c_char :

pub extern "C" fn sweversion() -> *const c_char { CString::new(handler_swe02::version()).unwrap().into_raw() }

For get a json with all svg and position inside as a pointer const c_char: pub extern "C" fn compute( year: c_int, month: c_int, day: c_int, hourf32: c_double, hour: c_int, min: c_int, sec: c_double, lat: c_double, lng: c_double, max_size: c_double, path: *const c_char, ) -> *const c_char { let d = DataChartNatalC { year: year, month: month, day: day, hourf32: hourf32, hour: hour, min: min, sec: sec, lat: lat, lng: lng, }; let path_c_str = unsafe { CStr::from_ptr(path) }; let path_str: &str = path_c_str.to_str().unwrap(); let data = astrology_draw_svg::chart(max_size as f32, d, &path_str); CString::new(serde_json::to_string(&data).unwrap()) .unwrap() .into_raw() }

For all aspects (only major at this moment)

```

[no_mangle]

pub extern "C" fn aspects() -> *const cchar { let data = astrologydrawsvg::allaspects(); CString::new(serdejson::tostring(&data).unwrap()) .unwrap() .into_raw() }

```

For transit

```

[no_mangle]

pub extern "C" fn computetransit( year: cint, month: cint, day: cint, hourf32: cdouble, hour: cint, min: cint, sec: cdouble, lat: cdouble, lng: cdouble, yeartransit: cint, monthtransit: cint, daytransit: cint, hourf32transit: cdouble, hourtransit: cint, mintransit: cint, sectransit: cdouble, lattransit: cdouble, lngtransit: cdouble, maxsize: cdouble, path: *const cchar, ) -> *const cchar { let d = DataChartNatalC { year: year, month: month, day: day, hourf32: hourf32, hour: hour, min: min, sec: sec, lat: lat, lng: lng, }; let dt = DataChartNatalC { year: yeartransit, month: monthtransit, day: daytransit, hourf32: hourf32transit, hour: hourtransit, min: mintransit, sec: sectransit, lat: lattransit, lng: lngtransit, }; let pathcstr = unsafe { CStr::fromptr(path) }; let pathstr: &str = pathcstr.tostr().unwrap(); let data = astrologydrawsvg::chartwithtransit( maxsize as f32, d, dt, &pathstr, ); CString::new(serdejson::tostring(&data).unwrap()) .unwrap() .into_raw() } ```

Version

0.1.1 * Update doc

0.1.0 * Some function for extern c use (c -> rust -> c)