diff --git a/src/core.rs b/src/core.rs new file mode 100644 index 0000000..7e239cf --- /dev/null +++ b/src/core.rs @@ -0,0 +1,16 @@ +//! Core types used in the processing of payments. + +/// Clients are anonymous, identified by globally unique ids. "16-bit ought to be enough for +/// anyone". +#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub struct ClientId(pub u16); + +/// Transactions are identified by a globally unique id. 32 bit is sufficient for our puposes. +#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub struct TxId(pub u32); + +/// Amounts are represented as exact decimals, up to four places past the decimal. +/// For ease of implementation, make use of [fpdec::Decimal] instead of implementing a custom +/// fixed-point number. +#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord)] +pub struct TxAmount(pub fpdec::Decimal); diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..77a59f8 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,2 @@ +pub mod core; +pub use crate::core::*;