commit 4f7360d5c53e3e7fb0dbafcee8af43aa073c20ee
parent 94528d206492f18ac502155996d7bf7dee28747b
Author: Antoine A <>
Date: Thu, 9 Apr 2026 12:09:44 +0200
common: make more type copy
Diffstat:
7 files changed, 19 insertions(+), 18 deletions(-)
diff --git a/common/taler-common/src/types/amount.rs b/common/taler-common/src/types/amount.rs
@@ -37,7 +37,9 @@ pub const FRAC_BASE_NB_DIGITS: u8 = 8;
/** The fraction part of an amount represents which fraction of the value */
pub const FRAC_BASE: u32 = 10u32.pow(FRAC_BASE_NB_DIGITS as u32);
-#[derive(Clone, PartialEq, Eq, serde_with::DeserializeFromStr, serde_with::SerializeDisplay)]
+#[derive(
+ Clone, Copy, PartialEq, Eq, serde_with::DeserializeFromStr, serde_with::SerializeDisplay,
+)]
/// Inlined ISO 4217 currency string
pub struct Currency(InlineStr<CURRENCY_LEN>);
@@ -266,7 +268,7 @@ pub fn decimal(decimal: impl AsRef<str>) -> Decimal {
/// <https://docs.taler.net/core/api-common.html#tsref-type-Amount>
#[derive(
- Debug, Clone, PartialEq, Eq, serde_with::DeserializeFromStr, serde_with::SerializeDisplay,
+ Debug, Clone, Copy, PartialEq, Eq, serde_with::DeserializeFromStr, serde_with::SerializeDisplay,
)]
pub struct Amount {
pub currency: Currency,
@@ -276,7 +278,7 @@ pub struct Amount {
impl Amount {
pub fn new_decimal(currency: &Currency, decimal: Decimal) -> Self {
- (currency.clone(), decimal).into()
+ (*currency, decimal).into()
}
pub fn new(currency: &Currency, val: u64, frac: u32) -> Self {
diff --git a/common/taler-common/src/types/utils.rs b/common/taler-common/src/types/utils.rs
@@ -18,7 +18,7 @@ use std::{fmt::Debug, ops::Deref};
use jiff::{Timestamp, civil::Date, tz::TimeZone};
-#[derive(Clone, PartialEq, Eq)]
+#[derive(Clone, Copy, PartialEq, Eq)]
pub struct InlineStr<const LEN: usize> {
/// Len of ascii string in buf
len: u8,
diff --git a/common/taler-test-utils/src/routine.rs b/common/taler-test-utils/src/routine.rs
@@ -397,7 +397,7 @@ pub async fn transfer_routine(
let req = TransferRequest {
request_uid,
- amount: default_amount.clone(),
+ amount: default_amount,
exchange_base_url: url("http://exchange.taler/"),
metadata: None,
wtid,
diff --git a/taler-cyclos/src/bin/cyclos-harness.rs b/taler-cyclos/src/bin/cyclos-harness.rs
@@ -147,7 +147,7 @@ impl<'a> Harness<'a> {
let db = &mut self.pool.acquire().await.unwrap().detach();
Worker {
db,
- currency: self.currency.clone(),
+ currency: self.currency,
client: &self.wire,
account_type: AccountType::Exchange,
account_type_id: self.account_type_id,
diff --git a/taler-cyclos/src/worker.rs b/taler-cyclos/src/worker.rs
@@ -81,7 +81,7 @@ pub async fn run_worker(
account_type_id: *cfg.account_type_id,
payment_type_id: *cfg.payment_type_id,
account_type: cfg.account_type,
- currency: cfg.currency.clone(),
+ currency: cfg.currency,
}
.run()
.await?;
@@ -131,7 +131,7 @@ pub async fn run_worker(
account_type_id: *cfg.account_type_id,
payment_type_id: *cfg.payment_type_id,
account_type: cfg.account_type,
- currency: cfg.currency.clone(),
+ currency: cfg.currency,
}
.run()
.await?;
diff --git a/taler-magnet-bank/src/db.rs b/taler-magnet-bank/src/db.rs
@@ -209,7 +209,7 @@ pub async fn register_tx_in_admin(
FROM register_tx_in(NULL, $1, $2, $3, $4, $5, $6, $7, $5)
",
)
- .bind(&tx.amount)
+ .bind(tx.amount)
.bind(&tx.subject)
.bind(tx.debtor.iban())
.bind(&tx.debtor.name)
@@ -250,7 +250,7 @@ pub async fn register_tx_in(
",
)
.bind(tx.code as i64)
- .bind(&tx.amount)
+ .bind(tx.amount)
.bind(&tx.subject)
.bind(tx.debtor.iban())
.bind(&tx.debtor.name)
@@ -317,7 +317,7 @@ pub async fn register_tx_out(
",
)
.bind(tx.code as i64)
- .bind(&tx.amount)
+ .bind(tx.amount)
.bind(&tx.subject)
.bind(tx.creditor.iban())
.bind(&tx.creditor.name)
@@ -460,7 +460,7 @@ pub async fn register_bounce_tx_in(
",
)
.bind(tx.code as i64)
- .bind(&tx.amount)
+ .bind(tx.amount)
.bind(&tx.subject)
.bind(tx.debtor.iban())
.bind(&tx.debtor.name)
@@ -1472,7 +1472,7 @@ mod test {
&mut db,
&TxIn {
code: 13,
- amount: amount.clone(),
+ amount,
subject: "subject".into(),
debtor: payto.clone(),
value_date: date,
@@ -1497,7 +1497,7 @@ mod test {
&mut db,
&TxIn {
code: 12,
- amount: amount.clone(),
+ amount,
subject: "subject".into(),
debtor: payto.clone(),
value_date: date,
@@ -1546,7 +1546,7 @@ mod test {
&mut db,
&TxIn {
code: 13,
- amount: amount.clone(),
+ amount,
subject: "subject".into(),
debtor: payto.clone(),
value_date: date,
@@ -1570,7 +1570,7 @@ mod test {
&mut db,
&TxIn {
code: 13,
- amount: amount.clone(),
+ amount,
subject: "subject".into(),
debtor: payto.clone(),
value_date: date,
@@ -1595,7 +1595,7 @@ mod test {
&[
Initiated {
id: 1,
- amount: amount.clone(),
+ amount,
subject: "bounce: 12".into(),
creditor: payto.clone()
},
diff --git a/taler-magnet-bank/src/dev.rs b/taler-magnet-bank/src/dev.rs
@@ -120,7 +120,6 @@ pub async fn dev(cfg: &Config, cmd: DevCmd) -> anyhow::Result<()> {
let account = client.account(debtor.bban()).await?;
let amount = creditor
.amount
- .clone()
.or(amount)
.ok_or_else(|| anyhow!("Missing amount"))?;
let subject = creditor