Skip to main content

Config

Struct Config 

Source
pub struct Config {
    pub year_divide: YearDivide,
    pub horoscope_divide: HoroscopeDivide,
    pub age_divide: AgeDivide,
    pub day_divide: DayDivide,
    pub algorithm: Algorithm,
    pub astro_type: AstroType,
    pub overrides: Option<Arc<TableOverrides>>,
}
Expand description

排盘配置:控制分界点、算法派别与自定义表的全部开关

Fields§

§year_divide: YearDivide

年分界点

§horoscope_divide: HoroscopeDivide

运限分界点

§age_divide: AgeDivide

虚岁分界点

§day_divide: DayDivide

晚子时归属

§algorithm: Algorithm

算法派别

§astro_type: AstroType

排盘视角(天盘/地盘/人盘)

§overrides: Option<Arc<TableOverrides>>

自定义四化与亮度表;None 表示全部使用默认表。

不参与序列化:它是排盘的输入配置,不属于排盘结果, 加入 DTO 会破坏与 JS iztro 的字段契约。

Implementations§

Source§

impl Config

Source

pub fn with_astro_type(self, astro_type: AstroType) -> Self

在当前配置上指定排盘视角。

Source

pub fn with_mutagens(self, stem: HeavenlyStem, stars: [StarKey; 4]) -> Self

在当前配置上覆盖某个天干的四化表。

Source

pub fn with_brightness( self, star: StarKey, table: [Option<Brightness>; 12], ) -> Self

在当前配置上覆盖某颗星的十二宫亮度表。

Source

pub fn mutagens_of(&self, stem: HeavenlyStem) -> [StarKey; 4]

该天干实际生效的四化表:有覆盖用覆盖,否则用默认表。

Source

pub fn brightness_of( &self, star: StarKey, palace_index: usize, ) -> Option<Brightness>

该星在指定宫位实际生效的亮度:有覆盖用覆盖,否则用默认表。

palace_index 为盘上位置(寅宫为 0),越界会对 12 取模。

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Config

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Config

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Config

Source§

fn default() -> Self

与 JS iztro 的默认配置一致

Source§

impl<'de> Deserialize<'de> for Config

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for Config

Source§

impl From<Config> for ConfigDto

Source§

fn from(c: Config) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Config

Source§

fn eq(&self, other: &Config) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Config

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Config

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.