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
use super::Service;
use crate::{ApiError, Error, ServiceClient};
use maybe_async::maybe_async;
mod request;
mod response;
/// Astronomy API requests.
pub use request::{AstroEventRequest, AstroPositionRequest};
/// Astronomy API responses.
pub use response::AstronomyResponse;
struct AstroEventService;
struct AstroPositionService;
impl Service for AstroEventService {
const PATH: &'static str = "astronomy";
type Request = AstroEventRequest;
type Response = AstronomyResponse;
}
impl Service for AstroPositionService {
const PATH: &'static str = "astrodata";
type Request = AstroPositionRequest;
type Response = AstronomyResponse;
}
impl ServiceClient {
#[maybe_async]
/// The *Astro Event* service can be used to retrieve the sunrise, sunset, moonrise, moonset,
/// solar noon and twilight times for all locations in our database. The service can also
/// return the azimuth of events, the altitude, and the distance to the sun for the noon event.
pub async fn get_astro_events(
&self,
request: &AstroEventRequest,
) -> Result<Result<AstronomyResponse, ApiError>, Error> {
self.call::<AstroEventService>(request).await
}
#[maybe_async]
/// The *Astro Position* service can be used to retrieve the altitude, azimuth and distance to
/// the Moon and the Sun for all locations in our database. The service also returns the moon
/// phase, the fraction of the Moon's illuminated side as well as the midpoint angle of the
/// Moon's bright limb at any point in time.
///
/// Unlike the Astro Event service, the Astro Position service can be queried on a specific
/// point in time, down to the second.
pub async fn get_astro_position(
&self,
request: &AstroPositionRequest,
) -> Result<Result<AstronomyResponse, ApiError>, Error> {
self.call::<AstroPositionService>(request).await
}
}