astro-core

Crates.ioastro-core
lib.rsastro-core
version0.2.0
created_at2025-12-09 22:00:17.164711+00
updated_at2026-01-08 18:43:33.823312+00
descriptionRust wrapper around the Swiss Ephemeris C library to compute Sun, Moon, and Ascendant signs from UTC birth data.
homepagehttps://github.com/volodymyrlekhman/astro-core
repositoryhttps://github.com/volodymyrlekhman/astro-core
max_upload_size
id1976821
size1,880,946
Volodymyr Lekhman (Lekhman-vold)

documentation

README

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

Commit count: 0

cargo fmt