# astro-core
Minimal Rust wrapper around the Swiss Ephemeris C library for computing Sun, Moon, and Ascendant signs from UTC birth data and location.
## Features
- Safe Rust API (`calculate_core_chart`) returning Sun, Moon, and Ascendant signs.
- Uses vendored Swiss Ephemeris C sources compiled via `cc` in `build.rs`.
- Configurable ephemeris data path (`set_ephe_path`); defaults to current dir.
## Getting Started
```bash
cargo build
cargo test # runs unit tests
cargo run --example basic
```
## Usage
```rust
use astro_core::{calculate_core_chart, set_ephe_path, BirthData};
fn main() -> Result<(), Box<dyn std::error::Error>> {
set_ephe_path("src/swisseph/ephe"); // adjust if your ephemeris files live elsewhere
let birth = BirthData {
year: 1990,
month: 7,
day: 15,
hour: 10,
minute: 30,
second: 0.0,
lat: 40.7128,
lon: -74.0060,
};
let chart = calculate_core_chart(&birth)?;
println!("Sun: {}, Moon: {}, Asc: {}", chart.sun_sign, chart.moon_sign, chart.asc_sign);
Ok(())
}
```
If the birth time is unknown, you can use a date-only helper. It returns Sun
sign from the date and leaves Moon/Asc as `None`:
```rust
use astro_core::{calculate_core_chart_date_only, set_ephe_path, BirthDate, BirthLocation};
fn main() -> Result<(), Box<dyn std::error::Error>> {
set_ephe_path("src/swisseph/ephe");
let date = BirthDate {
year: 1990,
month: 7,
day: 15,
};
let location = BirthLocation {
lat: 40.7128,
lon: -74.0060,
};
let chart = calculate_core_chart_date_only(&date, &location)?;
println!(
"Sun: {:?}, Moon: {:?}, Asc: {:?}",
chart.sun_sign, chart.moon_sign, chart.asc_sign
);
Ok(())
}
```
## Ephemeris Data
- C sources are vendored under `src/swisseph` and compiled automatically.
- Ephemeris data files are *not* included in the published crate to stay under the crates.io size limit. Download them from the upstream Swiss Ephemeris project (https://github.com/aloistr/swisseph) and point to the directory with `set_ephe_path("/path/to/ephe")`.
- Swiss Ephemeris is licensed separately; review `src/swisseph/LICENSE`.
## Development
- Formatting/lint: `cargo fmt`, `cargo clippy -- -D warnings`.
- Example run: `cargo run --example basic`.
- Warnings from the Swiss Ephemeris C code are upstream and expected; silence with `.warnings(false)` in `build.rs` if needed.
## Author
Volodymyr Lekhman — [LinkedIn](https://www.linkedin.com/in/volodymyr-lekhman-0a40121ab/)