1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
//! # Outfit environment state
//!
//! This module defines [`crate::env_state::OutfitEnv`], the **shared environment object** used across
//! the `Outfit` library. It provides access to:
//!
//! - A persistent **HTTP client** (for downloading ephemerides, observatory lists, etc.).
//! - A **UT1 provider** from [hifitime](https://docs.rs/hifitime) to handle Earth rotation
//! parameters from JPL.
//!
//! This object is designed to be **cheaply cloneable** and passed to algorithms
//! that require access to external data sources or Earth orientation models.
//!
//! ## Overview
//!
//! The main responsibilities of `OutfitEnv` are:
//!
//! 1. Manage a global [`ureq::Agent`] HTTP client with sensible default settings.
//! 2. Download and initialize an [`hifitime::ut1::Ut1Provider`] from JPL’s `latest_eop2.long` file
//! (Earth orientation parameters) at startup.
//! 3. Provide simple utilities for performing HTTP GET requests.
//!
//! ## Structure
//!
//! ```text
//! OutfitEnv
//! ├── http_client (ureq::Agent)
//! └── ut1_provider (hifitime::Ut1Provider)
//! ```
//!
//! ## Usage
//!
//! ```rust,ignore
//! use outfit::env_state::OutfitEnv;
//!
//! // Create a new environment (downloads UT1 data from JPL)
//! let env = OutfitEnv::new();
//!
//! // Access the UT1 provider
//! let ut1 = &env.ut1_provider;
//!
//! // Make a GET request using the built-in HTTP client
//! let response = env.get_from_url("https://ssd.jpl.nasa.gov/api/horizons.api");
//! println!("Response: {}", &response[..100.min(response.len())]);
//! ```
//!
//! ## Notes
//!
//! - The [`crate::env_state::OutfitEnv`] struct is meant to be reused and shared between different
//! parts of the crate to avoid redundant downloads and HTTP session creation.
//! - The UT1 provider is initialized once at startup; if fresh data is needed,
//! the library must be restarted or the provider re-downloaded manually.
//!
//! ## See also
//!
//! - [`hifitime::ut1::Ut1Provider`] – Manages Earth orientation and UT1 corrections.
//! - [`ureq::Agent`] – Minimal HTTP client used internally.
use Ut1Provider;
use TryFrom;
use ;
use ;
/// This object is passed to the various functions in the library
/// to provide access to the state of the library
///
/// # Fields
///
/// * `http_client` - A reqwest client used to make HTTP requests
/// * `ut1_provider` - A provider used to get the current UT1 time
/// * `observatories` - A lazy map of observatories from the Minor Planet Center.
/// The key is the MPC code and the value is the observer