taler-rust

GNU Taler code in Rust. Largely core banking integrations.
Log | Files | Refs | Submodules | README | LICENSE

commit 469b97592330438bc9f2f04be28dd92ecba80a2a
parent d379f9bc6cf4d50559e96f46f7ac2e68fc2c5b3f
Author: Antoine A <>
Date:   Thu,  6 Feb 2025 21:44:06 +0100

common: typos and code improvements

Signed-off-by: Antoine A <>

Diffstat:
Mcommon/taler-api/src/db.rs | 4++--
Mcommon/taler-api/src/json.rs | 20++++++++++++++++++--
Mcommon/taler-api/src/lib.rs | 2+-
Mcommon/taler-api/src/subject.rs | 6+++---
Mcommon/taler-common/src/config.rs | 2+-
Mcommon/taler-common/src/types/iban.rs | 4++--
Mcommon/taler-common/src/types/timestamp.rs | 4++--
Mcontrib/ci/jobs/0-codespell/dictionary.txt | 6++++--
Mtaler-magnet-bank/src/db.rs | 6+++---
Mtaler-magnet-bank/src/keys.rs | 2+-
Mtaler-magnet-bank/src/lib.rs | 2+-
11 files changed, 38 insertions(+), 20 deletions(-)

diff --git a/common/taler-api/src/db.rs b/common/taler-api/src/db.rs @@ -153,8 +153,8 @@ pub trait TypeHelper { index: I, map: M, ) -> sqlx::Result<R>; - fn try_get_parse<'r, I: sqlx::ColumnIndex<Self>, E: Into<BoxDynError>, T: FromStr<Err = E>>( - &'r self, + fn try_get_parse<I: sqlx::ColumnIndex<Self>, E: Into<BoxDynError>, T: FromStr<Err = E>>( + &self, index: I, ) -> sqlx::Result<T>; fn try_get_timestamp<I: sqlx::ColumnIndex<Self>>(&self, index: I) -> sqlx::Result<Timestamp> { diff --git a/common/taler-api/src/json.rs b/common/taler-api/src/json.rs @@ -1,3 +1,19 @@ +/* + This file is part of TALER + Copyright (C) 2025 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> +*/ + use axum::{ body::Bytes, extract::{FromRequest, Request}, @@ -47,13 +63,13 @@ where } // Check content length if present and wellformed - if let Some(lenght) = req + if let Some(length) = req .headers() .get(header::CONTENT_LENGTH) .and_then(|it| it.to_str().ok()) .and_then(|it| it.parse::<usize>().ok()) { - if lenght > MAX_BODY_LENGTH { + if length > MAX_BODY_LENGTH { return Err(failure( ErrorCode::GENERIC_JSON_INVALID, format!("Body is suspiciously big > {MAX_BODY_LENGTH}B"), diff --git a/common/taler-api/src/lib.rs b/common/taler-api/src/lib.rs @@ -38,7 +38,7 @@ pub enum Serve { } impl Serve { - /// Resolve listener from a config and environement + /// Resolve listener from a config and environment fn resolve(&self) -> Result<Listener, std::io::Error> { // Check if systemd is passing a socket let mut listenfd = ListenFd::from_env(); diff --git a/common/taler-api/src/subject.rs b/common/taler-api/src/subject.rs @@ -51,7 +51,7 @@ pub struct OutgoingSubject(pub ShortHashCode, pub Url); /** Base32 quality by proximity to spec and error probability */ #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] enum Base32Quality { - /// Both mixed casing and mixed characters, thats weird + /// Both mixed casing and mixed characters, that's weird Mixed, /// Standard but use lowercase, maybe the client shown lowercase in the UI Standard, @@ -209,7 +209,7 @@ pub fn parse_incoming_unstructured( *best = other } else if best.subject.key() != other.subject.key() // If keys are different && best.quality == other.quality // Of same quality - && !matches!( // And prefixing is diferent + && !matches!( // And prefixing is different (&best.subject.ty(), &other.subject.ty()), (IncomingType::kyc | IncomingType::wad, IncomingType::reserve) ) @@ -232,7 +232,7 @@ fn parse() { let key = "4MZT6RS3RVB3B0E2RDMYW0YRA3Y0VPHYV0CYDE6XBB0YMPFXCEG0"; let other = "00Q979QSMJ29S7BJT3DDAVC5A0DR5Z05B7N0QT1RCBQ8FXJPZ6RG"; - // Common checkes + // Common checks for ty in [IncomingType::reserve, IncomingType::kyc] { let prefix = match ty { IncomingType::reserve => "", diff --git a/common/taler-common/src/config.rs b/common/taler-common/src/config.rs @@ -414,7 +414,7 @@ pub mod parser { None => { if let Some(default) = src .default_config_path() - .map_err(|(p, e)| io_err("find defauld config path", p, e))? + .map_err(|(p, e)| io_err("find default config path", p, e))? { parser.parse_file(&default, 0)?; } diff --git a/common/taler-common/src/types/iban.rs b/common/taler-common/src/types/iban.rs @@ -214,7 +214,7 @@ pub enum BicErrorKind { Invalid, #[error("invalid check digit")] BankCode, - #[error("invalid contry code")] + #[error("invalid country code")] CountryCode, #[error("bad size expected 8 or {MAX_BIC_SIZE} chars for {0}")] Size(usize), @@ -299,7 +299,7 @@ fn parse_iban() { fn parse_bic() { for (valid, parts) in [ ("DEUTDEFF", ("DEUT", "DE", "FF", None)), // Deutsche Bank, Germany - ("NEDSZAJJ", ("NEDS", "ZA", "JJ", None)), // Nedbank, South Africa + ("NEDSZAJJ", ("NEDS", "ZA", "JJ", None)), // Nedbank, South Africa // codespell:ignore ("BARCGB22", ("BARC", "GB", "22", None)), // Barclays, UK ("CHASUS33XXX", ("CHAS", "US", "33", Some("XXX"))), // JP Morgan Chase, USA (branch) ("BNPAFRPP", ("BNPA", "FR", "PP", None)), // BNP Paribas, France diff --git a/common/taler-common/src/types/timestamp.rs b/common/taler-common/src/types/timestamp.rs @@ -17,7 +17,7 @@ use std::fmt::Display; use jiff::{civil::Time, tz::TimeZone}; -use serde::{de::Error, ser::SerializeStruct, Deserialize, Deserializer, Serialize, Serializer}; +use serde::{de::Error, ser::SerializeStruct, Deserialize, Deserializer, Serialize, Serializer}; // codespell:ignore use serde_json::Value; /// <https://docs.taler.net/core/api-common.html#tsref-type-Timestamp> @@ -41,7 +41,7 @@ impl Timestamp { /** Timestamp corresponding to now as it would be stored in db */ pub fn now_stable() -> Self { Self::from_sql_micros(Self::now().as_sql_micros()) - .expect("timestamp sql roundtrip must always succedd") + .expect("timestamp sql roundtrip must always succeed") } /** Timestamp corresponding to "never" */ diff --git a/contrib/ci/jobs/0-codespell/dictionary.txt b/contrib/ci/jobs/0-codespell/dictionary.txt @@ -4,4 +4,6 @@ # spelled in codespell_lib/data/dictionary.txt. F.e. if there is a word # 'foo' and you add 'Foo' _here_, codespell will continue to complain # about 'Foo'. -# -\ No newline at end of file +# +crate +ser:: +\ No newline at end of file diff --git a/taler-magnet-bank/src/db.rs b/taler-magnet-bank/src/db.rs @@ -570,7 +570,7 @@ pub async fn pending_batch<'a>( .await } -/** Update status of a sucessfull submitted initiated transaction */ +/** Update status of a successful submitted initiated transaction */ pub async fn initiated_submit_success<'a>( db: impl PgExecutor<'a>, id: u64, @@ -590,7 +590,7 @@ pub async fn initiated_submit_success<'a>( Ok(()) } -/** Update status of a sucessfull submitted initiated transaction */ +/** Update status of a successful submitted initiated transaction */ pub async fn initiated_submit_failure<'a>( db: impl PgExecutor<'a>, id: u64, @@ -647,7 +647,7 @@ mod test { async fn setup() -> (PgConnection, PgPool) { let pool = taler_test_utils::db_test_setup().await; db::db_init(&pool, false).await.expect("dbinit"); - let conn = pool.acquire().await.expect("aquire conn").leak(); + let conn = pool.acquire().await.expect("acquire conn").leak(); (conn, pool) } diff --git a/taler-magnet-bank/src/keys.rs b/taler-magnet-bank/src/keys.rs @@ -106,7 +106,7 @@ pub async fn setup(cfg: WorkerCfg, reset: bool) -> anyhow::Result<()> { let client = client.upgrade(keys.access_token.as_ref().unwrap()); info!("Setup Strong Customer Authentication"); - // TODO find a proper way to check if SCA is required without trigerring SCA.GLOBAL_FEATURE_NOT_ENABLED + // TODO find a proper way to check if SCA is required without triggering SCA.GLOBAL_FEATURE_NOT_ENABLED let request = client.request_sms_code().await?; println!( "A SCA code have been sent through {} to {}", diff --git a/taler-magnet-bank/src/lib.rs b/taler-magnet-bank/src/lib.rs @@ -106,7 +106,7 @@ pub enum HuIbanErr { CountryCode(String), #[error("invalid length expected 16 or 24 chars got {0}")] BbanSize(usize), - #[error("invalid checkum for {0} expected {1} got {2}")] + #[error("invalid checksum for {0} expected {1} got {2}")] Checksum(&'static str, u8, u8), #[error(transparent)] Iban(IbanErrorKind),