1#![warn(missing_docs)]
8
9#[allow(dead_code)]
14pub(crate) mod bridge;
15
16pub mod astro;
18pub mod data;
20pub mod dto;
22pub mod error;
24pub mod i18n;
26pub mod models;
28pub mod prompt;
30pub mod star;
32pub mod utils;
34
35#[cfg(feature = "python")]
36mod python;
37
38#[doc(hidden)]
40pub mod ffi;
41
42#[cfg(target_arch = "wasm32")]
43#[doc(hidden)]
44pub mod wasm;
45
46pub use astro::builder::{by_lunar, by_solar};
48pub use astro::horoscope::get_horoscope;
49pub use astro::palace::{get_five_elements_class, get_palace_names, get_soul_and_body};
50pub use astro::query::{
51 get_major_star_by_lunar_date, get_major_star_by_solar_date, get_sign_by_lunar_date,
52 get_sign_by_solar_date, get_zodiac_by_solar_date,
53};
54pub use data::stars::StarKey;
55pub use data::types::*;
56pub use error::{BridgeError, IztroError};
57pub use i18n::lookup::{key_of, key_of_in, translate_key};
58pub use i18n::{
59 translate_brightness, translate_earthly_branch, translate_five_elements_class,
60 translate_gender, translate_heavenly_stem, translate_horoscope_name, translate_mutagen,
61 translate_palace, translate_sign, translate_star, translate_time, translate_zodiac,
62};
63pub use models::astrolabe::{
64 Astrolabe, PalaceRef, PalaceTarget, RawChineseDate, RawDates, RawLunarDate, StarRef,
65};
66pub use models::horoscope::{
67 AgeItem, HoroscopeData, HoroscopeItem, HoroscopeRef, YearlyDecStar, YearlyItem,
68};
69pub use models::palace::{Decadal, PalaceData};
70pub use models::star::Star;
71pub use models::surpalaces::SurroundedPalaces;
72pub use prompt::{astrolabe_to_prompt, horoscope_to_prompt};
73
74pub fn by_solar_json(
79 solar_date: &str,
80 time_index: u8,
81 gender: Gender,
82 fix_leap: bool,
83 language: Language,
84 config: Config,
85) -> Result<String, IztroError> {
86 let astrolabe = by_solar(solar_date, time_index, gender, fix_leap, language, config)?;
87 Ok(serde_json::to_string(&astrolabe.to_dto())
88 .expect("DTO 只含字符串、数值与容器,序列化不会失败"))
89}
90
91pub fn by_lunar_json(
96 lunar_date: &str,
97 time_index: u8,
98 gender: Gender,
99 leap: LeapMonth,
100 language: Language,
101 config: Config,
102) -> Result<String, IztroError> {
103 let astrolabe = by_lunar(lunar_date, time_index, gender, leap, language, config)?;
104 Ok(serde_json::to_string(&astrolabe.to_dto())
105 .expect("DTO 只含字符串、数值与容器,序列化不会失败"))
106}