lib: add core type definitions

This commit is contained in:
Bruno BELANYI 2022-08-22 17:49:56 +02:00
parent 1ea0505098
commit eae54b8ce0
2 changed files with 18 additions and 0 deletions

16
src/core.rs Normal file
View File

@ -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);

2
src/lib.rs Normal file
View File

@ -0,0 +1,2 @@
pub mod core;
pub use crate::core::*;