use serde::{Deserialize, Serialize};
use crate::data::stars::StarKey;
use crate::data::types::*;
use crate::models::astrolabe::Astrolabe;
use crate::models::star::Star;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct HoroscopeItem {
pub index: usize,
pub name: String,
pub heavenly_stem: HeavenlyStem,
pub earthly_branch: EarthlyBranch,
pub palace_names: Vec<Palace>,
pub mutagen: Vec<StarKey>,
pub stars: Option<Vec<Vec<Star>>>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AgeItem {
#[serde(flatten)]
pub base: HoroscopeItem,
pub nominal_age: u32,
}
impl std::ops::Deref for AgeItem {
type Target = HoroscopeItem;
fn deref(&self) -> &HoroscopeItem {
&self.base
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct YearlyDecStar {
pub jiangqian12: Vec<StarKey>,
pub suiqian12: Vec<StarKey>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct YearlyItem {
#[serde(flatten)]
pub base: HoroscopeItem,
pub yearly_dec_star: YearlyDecStar,
}
impl std::ops::Deref for YearlyItem {
type Target = HoroscopeItem;
fn deref(&self) -> &HoroscopeItem {
&self.base
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct HoroscopeData {
pub solar_date: String,
pub lunar_date: String,
pub decadal: HoroscopeItem,
pub age: AgeItem,
pub yearly: YearlyItem,
pub monthly: HoroscopeItem,
pub daily: HoroscopeItem,
pub hourly: HoroscopeItem,
}
pub struct HoroscopeRef<'a> {
pub(crate) data: HoroscopeData,
pub(crate) astrolabe: &'a Astrolabe,
}
impl<'a> std::ops::Deref for HoroscopeRef<'a> {
type Target = HoroscopeData;
fn deref(&self) -> &Self::Target {
&self.data
}
}
impl<'a> HoroscopeRef<'a> {
pub fn data(&self) -> &HoroscopeData {
&self.data
}
pub fn astrolabe(&self) -> &'a Astrolabe {
self.astrolabe
}
pub fn into_data(self) -> HoroscopeData {
self.data
}
}