Implement Directive with enum_dispatch

korrat
May 6, 2024, 3:38 PM
HNSHOQVHZJHS5YGKFNCHOGRU3UM2BO5J63OOWW4A2ZJPBCQTDI7AC

Dependencies

  • [2] HMWEY23D Move core data types back into beancount-types
  • [3] 2JBFREZG enable additional warnings
  • [4] SEEWF7KX Implement metadata on transactions
  • [5] RI7HQBYA Add generator and parser for ISO20022 messages
  • [6] PXR534B2 Fix sorting between different directives on the same day
  • [7] UESS5YZE migrate dependencies into workspace manifest
  • [8] HWT4JVUE Fix clippy warnings
  • [9] XQHYMSDY Add importer for Union Investment transactions
  • [10] 4UOASAH3 Make Acc and AccountTemplate zero-copy deserializable
  • [11] YDK6X6PP add a library of important types for beancount
  • [12] JFZHDHYO Add a type for Beancount open directives
  • [13] SMBQYFPG Enable access to timestamps for directives
  • [14] OAOH3QOZ Extract metadata into separate crate
  • [15] NG5QXPZH Extract Account into separate crate
  • [16] R524JUUE Implement metadata & price directives
  • [17] OUMCH6BS Add a crate for Beancount close directive
  • [*] E2DDQ4MX Define inheritable lints configuration
  • [*] D6UTHZA4 add a simple writer for saving a set of directives to a tree of files
  • [*] TRPNBZBO Support conversion from Open to Directive
  • [*] I2P2FTLE add basic parser for german decimals
  • [*] 6MR76MLL Replace build script with cargo-px
  • [*] 72AIO2FZ Upgrade dependencies

Change contents

  • edit in beancount/types/src/lib.rs at line 19
    [2.76189]
    [2.76189]
    pub use crate::directive::Interface as DirectiveInterface;
  • edit in beancount/types/src/directive.rs at line 4
    [2.8645]
    [2.8645]
    use enum_dispatch::enum_dispatch;
  • edit in beancount/types/src/directive.rs at line 17
    [2.8877]
    [2.8877]
    use self::seal::Sealed;
  • edit in beancount/types/src/directive.rs at line 25
    [2.8960]
    [2.8960]
    mod seal {
    #[enum_dispatch::enum_dispatch]
    pub trait Sealed {}
    }
  • edit in beancount/types/src/directive.rs at line 31
    [2.8961]
    [2.8961]
    #[enum_dispatch(Interface, Sealed)]
  • replacement in beancount/types/src/directive.rs at line 35
    [2.9075][2.9075:9179]()
    Balance(Balance),
    Close(Close),
    Open(Open),
    Price(Price),
    Transaction(Transaction),
    [2.9075]
    [2.9179]
    Balance,
    Close,
    Open,
    Price,
    Transaction,
  • edit in beancount/types/src/directive.rs at line 71
    [2.9886][2.9886:10174](),[2.10174][2.10174:10220](),[2.10220][2.10220:10406]()
    delegate! {
    to match self {
    Self::Balance(inner) => inner,
    Self::Close(inner) => inner,
    Self::Open(inner) => inner,
    Self::Price(inner) => inner,
    Self::Transaction(inner) => inner,
    } {
    #[must_use]
    pub const fn date(&self) -> Date;
    #[must_use]
    pub fn main_account(&self) -> Option<&Acc>;
    #[must_use]
    pub fn timestamp(&self) -> Option<OffsetDateTime>;
    }
    }
  • replacement in beancount/types/src/directive.rs at line 91
    [2.10894][2.10894:10996](),[2.10996][2.10996:11004](),[2.11004][2.11004:11005](),[2.11005][2.11005:11109](),[2.11109][2.11109:11110](),[2.11110][2.11110:11211]()
    impl From<Balance> for Directive {
    fn from(value: Balance) -> Self {
    Self::Balance(value)
    }
    }
    impl From<Close> for Directive {
    fn from(value: Close) -> Self {
    Self::Close(value)
    }
    }
    impl From<Open> for Directive {
    fn from(value: Open) -> Self {
    Self::Open(value)
    }
    }
    [2.10894]
    [2.11211]
    #[enum_dispatch]
    pub trait Interface: Sealed {
    #[must_use]
    fn date(&self) -> Date;
  • replacement in beancount/types/src/directive.rs at line 96
    [2.11212][2.11212:11314](),[2.11314][2.11314:11316]()
    impl From<Price> for Directive {
    fn from(value: Price) -> Self {
    Self::Price(value)
    }
    }
    [2.11212]
    [2.11316]
    #[must_use]
    fn main_account(&self) -> Option<&Acc>;
  • replacement in beancount/types/src/directive.rs at line 99
    [2.11317][2.11317:11437]()
    impl From<Transaction> for Directive {
    fn from(value: Transaction) -> Self {
    Self::Transaction(value)
    }
    [2.11317]
    [2.11437]
    #[must_use]
    fn timestamp(&self) -> Option<OffsetDateTime>;
  • replacement in beancount/types/src/directive/transaction.rs at line 335
    [3.2107][3.10207:10226]()
    impl Transaction {
    [3.2107]
    [2.77253]
    impl super::Interface for Transaction {
  • replacement in beancount/types/src/directive/transaction.rs at line 338
    [3.91793046][2.77268:77307]()
    pub const fn date(&self) -> Date {
    [3.91793046]
    [2.77307]
    fn date(&self) -> Date {
  • replacement in beancount/types/src/directive/transaction.rs at line 344
    [2.77362][3.91793046:91793095](),[3.91793046][3.91793046:91793095]()
    pub fn main_account(&self) -> Option<&Acc> {
    [2.77362]
    [3.10275]
    fn main_account(&self) -> Option<&Acc> {
  • replacement in beancount/types/src/directive/transaction.rs at line 352
    [2.77379][3.112:168](),[3.112][3.112:168]()
    pub fn timestamp(&self) -> Option<OffsetDateTime> {
    [2.77379]
    [3.10372]
    fn timestamp(&self) -> Option<OffsetDateTime> {
  • edit in beancount/types/src/directive/transaction.rs at line 396
    [3.2425]
    impl super::seal::Sealed for Transaction {}
  • replacement in beancount/types/src/directive/price.rs at line 81
    [2.77579][2.77579:77592]()
    impl Price {
    [2.77579]
    [2.77592]
    impl super::Interface for Price {
  • replacement in beancount/types/src/directive/price.rs at line 84
    [2.77622][2.77622:77661]()
    pub const fn date(&self) -> Date {
    [2.77622]
    [2.77661]
    fn date(&self) -> Date {
  • replacement in beancount/types/src/directive/price.rs at line 90
    [2.77716][2.77716:77771]()
    pub const fn main_account(&self) -> Option<&Acc> {
    [2.77716]
    [2.77771]
    fn main_account(&self) -> Option<&Acc> {
  • replacement in beancount/types/src/directive/price.rs at line 96
    [2.77821][2.77821:77877]()
    pub fn timestamp(&self) -> Option<OffsetDateTime> {
    [2.77821]
    [2.77877]
    fn timestamp(&self) -> Option<OffsetDateTime> {
  • edit in beancount/types/src/directive/price.rs at line 121
    [3.1816]
    impl super::seal::Sealed for Price {}
  • replacement in beancount/types/src/directive/open.rs at line 115
    [3.3096][3.3096:3108]()
    impl Open {
    [3.3096]
    [2.78317]
    impl super::Interface for Open {
  • replacement in beancount/types/src/directive/open.rs at line 118
    [2.78347][2.78347:78386]()
    pub const fn date(&self) -> Date {
    [2.78347]
    [2.78386]
    fn date(&self) -> Date {
  • replacement in beancount/types/src/directive/open.rs at line 124
    [2.78441][2.78441:78490]()
    pub fn main_account(&self) -> Option<&Acc> {
    [2.78441]
    [2.78490]
    fn main_account(&self) -> Option<&Acc> {
  • replacement in beancount/types/src/directive/open.rs at line 130
    [3.3138][3.3138:3194]()
    pub fn timestamp(&self) -> Option<OffsetDateTime> {
    [3.3138]
    [2.78526]
    fn timestamp(&self) -> Option<OffsetDateTime> {
  • edit in beancount/types/src/directive/open.rs at line 164
    [3.4022]
    impl super::seal::Sealed for Open {}
  • replacement in beancount/types/src/directive/close.rs at line 75
    [3.1715][3.1715:1728]()
    impl Close {
    [3.1715]
    [2.78936]
    impl super::Interface for Close {
  • replacement in beancount/types/src/directive/close.rs at line 78
    [2.78966][2.78966:79005]()
    pub const fn date(&self) -> Date {
    [2.78966]
    [2.79005]
    fn date(&self) -> Date {
  • replacement in beancount/types/src/directive/close.rs at line 84
    [2.79060][2.79060:79109]()
    pub fn main_account(&self) -> Option<&Acc> {
    [2.79060]
    [2.79109]
    fn main_account(&self) -> Option<&Acc> {
  • replacement in beancount/types/src/directive/close.rs at line 90
    [3.1758][3.1758:1814]()
    pub fn timestamp(&self) -> Option<OffsetDateTime> {
    [3.1758]
    [2.79145]
    fn timestamp(&self) -> Option<OffsetDateTime> {
  • edit in beancount/types/src/directive/close.rs at line 114
    [3.2416]
    impl super::seal::Sealed for Close {}
  • replacement in beancount/types/src/directive/balance.rs at line 81
    [3.13179][3.13179:13194]()
    impl Balance {
    [3.13179]
    [2.79462]
    impl super::Interface for Balance {
  • replacement in beancount/types/src/directive/balance.rs at line 84
    [2.79492][2.79492:79531]()
    pub const fn date(&self) -> Date {
    [2.79492]
    [2.79531]
    fn date(&self) -> Date {
  • replacement in beancount/types/src/directive/balance.rs at line 90
    [2.79586][2.79586:79635]()
    pub fn main_account(&self) -> Option<&Acc> {
    [2.79586]
    [2.79635]
    fn main_account(&self) -> Option<&Acc> {
  • replacement in beancount/types/src/directive/balance.rs at line 96
    [3.13224][3.1235:1291](),[3.1235][3.1235:1291]()
    pub fn timestamp(&self) -> Option<OffsetDateTime> {
    [3.13224]
    [2.79671]
    fn timestamp(&self) -> Option<OffsetDateTime> {
  • edit in beancount/types/src/directive/balance.rs at line 121
    [3.9801]
    impl super::seal::Sealed for Balance {}
  • edit in beancount/types/Cargo.toml at line 10
    [3.25977]
    [3.2336]
    # Inherited dependencies
    arrayvec.workspace = true
    delegate.workspace = true
    enum-kinds.workspace = true
    enum_dispatch.workspace = true
    lazy-regex.workspace = true
    miette.workspace = true
    momo.workspace = true
    once_cell.workspace = true
    regex.workspace = true
    rust_decimal.workspace = true
    serde.workspace = true
    snafu.workspace = true
    tap.workspace = true
    time.workspace = true
    time-tz.workspace = true
  • edit in beancount/types/Cargo.toml at line 35
    [3.25977][3.226:251](),[3.251][3.14857:14917](),[3.14917][3.454:484](),[3.484][3.14917:15067](),[3.14917][3.14917:15067](),[3.15067][3.381:411](),[3.381][3.381:411](),[3.411][3.15068:15158](),[3.15188][3.15188:15218](),[3.15218][3.237:267]()
    # Inherited dependencies
    arrayvec.workspace = true
    delegate.workspace = true
    enum-kinds.workspace = true
    lazy-regex.workspace = true
    miette.workspace = true
    momo.workspace = true
    once_cell.workspace = true
    regex.workspace = true
    rust_decimal.workspace = true
    serde.workspace = true
    snafu.workspace = true
    tap.workspace = true
    time.workspace = true
    time-tz.workspace = true
  • resolve order conflict in beancount/types/Cargo.toml at line 35
    [19.26]
  • edit in beancount/tree-writer/src/lib.rs at line 19
    [20.191]
    [21.1403]
    use beancount_types::DirectiveInterface as _;
  • edit in Cargo.toml at line 36
    [3.703]
    [23.2856]
    enum_dispatch = "0.3.13"
  • edit in Cargo.lock at line 479
    [3.719]
    [3.26627]
    "enum_dispatch",
  • edit in Cargo.lock at line 1113
    [24.10183]
    [24.10183]
    ]
    [[package]]
    name = "enum_dispatch"
    version = "0.3.13"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "aa18ce2bc66555b3218614519ac839ddb759a7d6720732f979ef8d13be147ecd"
    dependencies = [
    "once_cell",
    "proc-macro2",
    "quote",
    "syn 2.0.58",