From fd81550cd9b49c138f384dd7c097729d66f1e0b0 Mon Sep 17 00:00:00 2001 From: rtkay123 Date: Fri, 8 Aug 2025 08:01:13 +0200 Subject: build(proto): compile time iso20022 types --- lib/warden-core/src/google.rs | 8 ++++++++ lib/warden-core/src/iso20022.rs | 32 ++++++++++++++++++++++++++++++++ lib/warden-core/src/lib.rs | 27 +++++++++++++++------------ 3 files changed, 55 insertions(+), 12 deletions(-) create mode 100644 lib/warden-core/src/google.rs create mode 100644 lib/warden-core/src/iso20022.rs (limited to 'lib/warden-core/src') diff --git a/lib/warden-core/src/google.rs b/lib/warden-core/src/google.rs new file mode 100644 index 0000000..365766c --- /dev/null +++ b/lib/warden-core/src/google.rs @@ -0,0 +1,8 @@ +/// Well known types +pub mod protobuf { + include!(concat!(env!("OUT_DIR"), "/google.protobuf.rs")); +} + +pub mod r#type { + include!(concat!(env!("OUT_DIR"), "/google.r#type.rs")); +} diff --git a/lib/warden-core/src/iso20022.rs b/lib/warden-core/src/iso20022.rs new file mode 100644 index 0000000..e9e4a24 --- /dev/null +++ b/lib/warden-core/src/iso20022.rs @@ -0,0 +1,32 @@ +#[derive(Debug)] +pub enum TransactionType { + PACS008, + PACS002, +} + +impl std::fmt::Display for TransactionType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!( + f, + "{}", + match self { + TransactionType::PACS002 => "pacs.002.001.12", + TransactionType::PACS008 => "pacs.008.001.12", + } + ) + } +} + +/// Pacs008 file descriptor +pub const ISO20022_FILE_DESCRIPTOR_SET: &[u8] = + tonic::include_file_descriptor_set!("iso20022_descriptor"); + +/// pacs.008.001.12 +pub mod pacs008 { + tonic::include_proto!("iso20022.pacs008"); +} + +/// pacs.002.001.12 +pub mod pacs002 { + tonic::include_proto!("iso20022.pacs002"); +} diff --git a/lib/warden-core/src/lib.rs b/lib/warden-core/src/lib.rs index b93cf3f..111ce5d 100644 --- a/lib/warden-core/src/lib.rs +++ b/lib/warden-core/src/lib.rs @@ -1,14 +1,17 @@ -pub fn add(left: u64, right: u64) -> u64 { - left + right -} +//! warden-core +#![cfg_attr(docsrs, feature(doc_cfg))] +#![warn( + missing_docs, + rustdoc::broken_intra_doc_links, + missing_debug_implementations +)] -#[cfg(test)] -mod tests { - use super::*; +/// Google well known types +#[allow(missing_docs)] +#[cfg(feature = "iso20022")] +pub mod google; - #[test] - fn it_works() { - let result = add(2, 2); - assert_eq!(result, 4); - } -} +/// ISO20022 messages +#[allow(missing_docs)] +#[cfg(feature = "iso20022")] +pub mod iso20022; -- cgit v1.2.3