Expand description
Backend contracts, metadata, and adapter helpers for ephemeris providers.
This crate defines the shared request/response shape used by all backend
families. Concrete backends live in their own pleiades-* crates and
implement EphemerisBackend.
Enable the optional serde feature to serialize the shared request,
result, metadata, and error types used by backend implementations.
The current time-scale, observer, apparentness, and frame policy is
documented in docs/time-observer-policy.md so the direct backend contract
and the façade-level request helpers stay in sync. Direct batch callers
should pair that policy with validate_requests_against_metadata() so the
same explicit contract is checked before a slice of requests is dispatched.
§Examples
use pleiades_backend::{EphemerisBackend, EphemerisRequest, BackendMetadata, BackendId, BackendFamily,
BackendProvenance, BackendCapabilities, AccuracyClass, TimeRange, EphemerisResult, EphemerisError,
EphemerisErrorKind, Apparentness, QualityAnnotation, BodyClaim};
use pleiades_types::{CelestialBody, CoordinateFrame, Instant, JulianDay, Latitude,
Longitude, TimeScale, ZodiacMode};
struct ToyBackend;
impl EphemerisBackend for ToyBackend {
fn metadata(&self) -> BackendMetadata {
BackendMetadata {
id: BackendId::new("toy"),
version: "0.1.0".to_string(),
family: BackendFamily::Algorithmic,
provenance: BackendProvenance { summary: "example backend".to_string(), data_sources: vec![] },
nominal_range: TimeRange::new(None, None),
supported_time_scales: vec![TimeScale::Tt],
body_claims: vec![BodyClaim::from(CelestialBody::Sun)],
supported_frames: vec![CoordinateFrame::Ecliptic],
capabilities: BackendCapabilities::default(),
accuracy: AccuracyClass::Approximate,
deterministic: true,
offline: true,
}
}
fn supports_body(&self, body: CelestialBody) -> bool {
body == CelestialBody::Sun
}
fn position(&self, request: &EphemerisRequest) -> Result<EphemerisResult, EphemerisError> {
if request.body != CelestialBody::Sun {
return Err(EphemerisError::new(EphemerisErrorKind::UnsupportedBody, "only the Sun is supported"));
}
Ok(EphemerisResult::new(
BackendId::new("toy"),
request.body.clone(),
request.instant,
request.frame,
request.zodiac_mode.clone(),
request.apparent,
))
}
}Modules§
- test_
backend - Deterministic analytic Sun/Moon backend for downstream tests. NOT for production: circular-orbit longitudes, fixed distances.
Structs§
- Angle
- An angular quantity measured in degrees.
- Backend
Capabilities - Capability flags for a backend.
- Backend
Id - Stable identifier for a backend implementation.
- Backend
Metadata - Nominal backend metadata.
- Backend
Provenance - Provenance summary for a backend.
- Body
Claim - A single backend’s claim about a single body.
- Composite
Backend - A simple composite backend that routes requests to one of two providers.
- Custom
Ayanamsa - A structured custom ayanamsa definition.
- Custom
Body Id - A structured identifier for a custom body.
- Custom
House System - A structured custom house-system definition.
- Ecliptic
Coordinates - Ecliptic position data.
- Ephemeris
Error - A structured backend error.
- Ephemeris
Request - A backend request.
- Ephemeris
Result - A backend result containing the requested coordinates where available.
- Equatorial
Coordinates - Equatorial position data.
- Frame
Treatment Summary - Compact summary of a backend’s frame-treatment posture.
- Instant
- A Julian day tagged with a time scale.
- Julian
Day - A Julian day expressed as a floating-point day count.
- Latitude
- A signed latitude-like angle measured in degrees, north-positive.
- Longitude
- A canonical ecliptic or longitude-like angle normalized into
[0, 360). - Motion
- Apparent motion data for a position sample.
- Observer
Location - A geographic observer location.
- Release
Posture - A derived, cross-backend view of body claims for release reporting.
- Routing
Backend - A routing backend that can chain any number of providers.
- Time
Range - A Julian-day interval.
- Time
Scale Conversion - A caller-supplied time-scale conversion policy.
Enums§
- Accuracy
Class - A rough accuracy class for a backend.
- Apparentness
- Whether a backend should prefer apparent or mean values where both exist.
- Ayanamsa
- A built-in or custom ayanamsa selection.
- Backend
Capabilities Validation Error - Errors returned when the declared backend capabilities cannot describe a usable request shape.
- Backend
Family - The high-level backend family.
- Backend
Family Posture - A coarse posture label for how a backend family is typically categorized in release summaries.
- Backend
Metadata Validation Error - Errors returned when backend metadata fails the shared consistency checks.
- Backend
Provenance Validation Error - Errors returned when backend provenance metadata fails the shared consistency checks.
- Body
Claim Tier - The release-claim status of a single body for a single backend.
- Celestial
Body - The built-in and custom body identifiers recognized by the shared API.
- Celestial
Body Class - A coarse classification for a celestial body.
- Claim
Evidence - The evidence backing a body claim.
- Coordinate
Frame - The coordinate frame requested from a backend.
- Coordinate
Validation Error - Validation errors for shared coordinate samples.
- Custom
Definition Validation Error - Validation failure for a custom body, house system, or ayanamsa definition.
- Ephemeris
Error Kind - Error categories for backend queries.
- Ephemeris
Result Validation Error - Errors returned when a backend result record no longer matches its stored data.
- Frame
Treatment Summary Validation Error - Validation error for a frame-treatment summary that drifted away from a compact release-facing line.
- House
System - A built-in or custom house system selection.
- Motion
Validation Error - Errors returned when motion samples contain non-finite values.
- Quality
Annotation - Quality annotation for a backend result.
- Time
Range Validation Error - Shared validation errors for
TimeRange. - Time
Scale - A supported astronomical time scale.
- Time
Scale Conversion Error - Error returned when a caller-provided time-scale conversion fails.
- Zodiac
Mode - Whether coordinates should be interpreted in tropical or sidereal mode.
Traits§
- Ephemeris
Backend - The shared backend contract.
Functions§
- merge_
body_ claims - Merges two claim lists, keeping the stronger-ranked tier on body collisions.
- validate_
observer_ policy - Validates the observer policy shared by the current first-party backends.
- validate_
request_ against_ metadata - Validates a direct backend request against the published backend metadata.
- validate_
request_ policy - Validates the request-shape policy shared by the current first-party backends.
- validate_
requests_ against_ metadata - Validates a batch of direct backend requests against backend metadata.
- validate_
zodiac_ policy - Validates the zodiac-mode policy shared by the current first-party backends.