taler-rust

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

commit fef23a786747b8c19de617a3b4538913edb9064a
parent 0c59fcc3d702ee648381ad152cd1adbd223546ff
Author: Antoine A <>
Date:   Thu, 30 Apr 2026 20:40:27 +0200

common: typo

Diffstat:
Mcommon/taler-common/src/bench.rs | 14+++++++-------
Mcommon/taler-common/src/types/timestamp.rs | 31+++++++++++++++++++++++++++++++
Mcontrib/ci/jobs/0-codespell/dictionary.txt | 5+++--
3 files changed, 41 insertions(+), 9 deletions(-)

diff --git a/common/taler-common/src/bench.rs b/common/taler-common/src/bench.rs @@ -229,7 +229,7 @@ fn print_table(columns: &[&str], rows: &[Vec<String>], separator: char, col_styl let mut table = String::new(); - let padd = |buf: &mut String, len: usize| { + let pad = |buf: &mut String, len: usize| { for _ in 0..len { buf.push(' '); } @@ -240,10 +240,10 @@ fn print_table(columns: &[&str], rows: &[Vec<String>], separator: char, col_styl table.push(separator); } - let pad = len - display_length(name); - padd(&mut table, pad / 2); + let pad_len = len - display_length(name); + pad(&mut table, pad_len / 2); table.push_str(name); - padd(&mut table, pad / 2 + pad % 2); + pad(&mut table, pad_len / 2 + pad_len % 2); } table.push('\n'); @@ -254,13 +254,13 @@ fn print_table(columns: &[&str], rows: &[Vec<String>], separator: char, col_styl } let style = col_style.get(i).cloned().unwrap_or_default(); - let pad = len - display_length(str_val); + let pad_len = len - display_length(str_val); if style.align_left { table.push_str(str_val); - padd(&mut table, pad); + pad(&mut table, pad_len); } else { - padd(&mut table, pad); + pad(&mut table, pad_len); table.push_str(str_val); } } diff --git a/common/taler-common/src/types/timestamp.rs b/common/taler-common/src/types/timestamp.rs @@ -106,6 +106,37 @@ impl Add<jiff::Span> for TalerTimestamp { } } +impl sqlx::Type<sqlx::Postgres> for TalerTimestamp { + fn type_info() -> <sqlx::Postgres as sqlx::Database>::TypeInfo { + Option::<i64>::type_info() + } +} + +impl<'q> sqlx::Encode<'q, sqlx::Postgres> for TalerTimestamp { + fn encode_by_ref( + &self, + buf: &mut <sqlx::Postgres as sqlx::Database>::ArgumentBuffer<'q>, + ) -> Result<sqlx::encode::IsNull, sqlx::error::BoxDynError> { + match self { + TalerTimestamp::Never => None, + TalerTimestamp::Timestamp(timestamp) => Some(timestamp.as_microsecond()), + } + .encode_by_ref(buf) + } +} + +impl<'r> sqlx::Decode<'r, sqlx::Postgres> for TalerTimestamp { + fn decode( + value: <sqlx::Postgres as sqlx::Database>::ValueRef<'r>, + ) -> Result<Self, sqlx::error::BoxDynError> { + let micros = Option::<i64>::decode(value)?; + Ok(match micros { + Some(micros) => Self::Timestamp(Timestamp::from_microsecond(micros)?), + None => Self::Never, + }) + } +} + /// <https://docs.taler.net/core/api-common.html#tsref-type-RelativeTime> #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] pub enum RelativeTime { diff --git a/contrib/ci/jobs/0-codespell/dictionary.txt b/contrib/ci/jobs/0-codespell/dictionary.txt @@ -6,4 +6,5 @@ # about 'Foo'. # crate -ser -\ No newline at end of file +ser +fo +\ No newline at end of file