assist_rs/lib.rs
1//! High-level domain layer for ASSIST + REBOUND solar-system propagation.
2//!
3//! The raw FFI bindings and safe RAII wrappers live in the companion
4//! `libassist-sys` crate (which itself depends on `librebound-sys` for the
5//! REBOUND C ABI). This crate adds:
6//!
7//! - [`Orbit`] + [`NonGravParams`] + [`Origin`] + [`AssistData`]: domain
8//! types for orbital states, non-gravitational coefficients, coordinate
9//! origins, and the bundled (ephemeris + observatory table) data handle.
10//! - [`ObservatoryTable`] + [`earth_orientation`]: MPC observatory lookups
11//! and Earth-orientation kernel handling for topocentric observations.
12//! - [`propagate`]: single-orbit + batched + rayon-parallel propagators,
13//! [`PropagatorPool`] for reusing simulations across many orbits, and STM
14//! + covariance propagation.
15//! - [`ephemeris`]: topocentric ephemeris generation with light-time
16//! iteration.
17//! - [`data`] (feature `data`): a [`data::DataManager`] that fetches +
18//! caches ephemeris and Earth-orientation kernels.
19//!
20//! All of `libassist-sys`'s public surface is re-exported here so downstream
21//! consumers can keep a single `assist_rs` import.
22
23mod assist_data;
24pub mod coordinates;
25#[cfg(feature = "data")]
26pub mod data;
27pub mod earth_orientation;
28pub mod ephemeris;
29mod observatory;
30mod orbit;
31mod origin;
32pub mod propagate;
33mod state;
34
35pub use assist_data::AssistData;
36pub use coordinates::{ecliptic_to_equatorial, equatorial_to_ecliptic};
37pub use ephemeris::{
38 EphemerisResult, Observer, assist_generate_ephemeris, assist_generate_ephemeris_single,
39};
40pub use observatory::ObservatoryTable;
41pub use orbit::{NonGravParams, Orbit};
42pub use origin::Origin;
43pub use propagate::{
44 PropagatedState, PropagatorConfig, PropagatorPool, assist_propagate, assist_propagate_single,
45};
46pub use state::{BodyState, assist_get_state};
47
48// Re-export the FFI + RAII layer so downstream code keeps using `assist_rs::*`
49// for both domain types and low-level sim/ephemeris handles.
50pub use libassist_sys::{
51 AssistSim, Ephemeris, Ias15AdaptiveMode, IntegratorConfig, Simulation, ffi,
52};
53// Re-export the sys crates themselves so downstream code can pattern-match on
54// nested error variants (Error::Sys(libassist_sys::Error::Reb(_))) and access
55// raw FFI symbols by their canonical paths if needed.
56pub use {libassist_sys, librebound_sys};
57
58/// Error type for assist-rs operations.
59#[derive(Debug, thiserror::Error)]
60pub enum Error {
61 /// Wrapped FFI-layer error from libassist-sys (which itself wraps
62 /// `librebound_sys::Error` for REBOUND integration-exit conditions).
63 #[error(transparent)]
64 Sys(#[from] libassist_sys::Error),
65
66 #[error("light-time iteration did not converge after {0} iterations")]
67 LightTimeConvergence(usize),
68
69 #[error("invalid body identifier: {0}")]
70 InvalidBody(String),
71
72 #[error("invalid observatory code: {0}")]
73 InvalidObservatory(String),
74
75 #[error(
76 "observatory {0} requires Earth orientation kernel; \
77 attach via ObservatoryTable::with_earth_orientation"
78 )]
79 MissingEarthOrientation(String),
80
81 #[error("I/O error: {0}")]
82 Io(#[from] std::io::Error),
83
84 #[error("{0}")]
85 Other(String),
86}
87
88impl From<librebound_sys::Error> for Error {
89 fn from(e: librebound_sys::Error) -> Self {
90 Error::Sys(libassist_sys::Error::Reb(e))
91 }
92}
93
94pub type Result<T> = std::result::Result<T, Error>;