From 17e7bb9988338f06a22849d3732e50582f50326d Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Tue, 23 Aug 2022 14:29:27 +0200 Subject: [PATCH] core: implement display for all core types --- src/core.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/core.rs b/src/core.rs index 8e62c1d..ec1c9b5 100644 --- a/src/core.rs +++ b/src/core.rs @@ -12,6 +12,12 @@ use serde_with::{serde_as, DisplayFromStr}; #[serde(transparent)] pub struct ClientId(pub u16); +impl std::fmt::Display for ClientId { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + self.0.fmt(f) + } +} + /// 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, Deserialize, Serialize, @@ -19,6 +25,12 @@ pub struct ClientId(pub u16); #[serde(transparent)] pub struct TxId(pub u32); +impl std::fmt::Display for TxId { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + self.0.fmt(f) + } +} + /// 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. @@ -31,6 +43,12 @@ impl TxAmount { pub const ZERO: Self = Self(Dec!(0)); } +impl std::fmt::Display for TxAmount { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + self.0.fmt(f) + } +} + impl std::ops::Add for TxAmount { type Output = Self;