astro-core 0.2.0

Rust wrapper around the Swiss Ephemeris C library to compute Sun, Moon, and Ascendant signs from UTC birth data.
Documentation
  • Coverage
  • 25.58%
    11 out of 43 items documented0 out of 13 items with examples
  • Size
  • Source code size: 1.88 MB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 748.02 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 28s Average build duration of successful builds.
  • all releases: 28s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Lekhman-vold

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

cargo build
cargo test            # runs unit tests
cargo run --example basic

Usage

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:

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