currencies in client never drifts from the server from now on

This commit is contained in:
Priec
2026-09-02 17:12:26 +02:00
parent 4ba518ab4e
commit 94ea9d1f7f
6 changed files with 28 additions and 2 deletions

2
client

Submodule client updated: 474b9761ce...a46ff11093

View File

@@ -743,4 +743,8 @@ message ListColumnTypesResponse {
// Every column type, declarable or not, ordered by name. // Every column type, declarable or not, ordered by name.
repeated ColumnType column_types = 1; repeated ColumnType column_types = 1;
// Every canonical ISO-4217 code accepted by currency-bearing columns and
// profile accounting settings, ordered alphabetically.
repeated string currency_codes = 2;
} }

View File

@@ -18,6 +18,24 @@ pub fn require_iso_currency_code(currency_code: &str) -> Result<&'static iso::Cu
iso::find(currency_code).ok_or_else(|| format!("Unknown ISO-4217 currency: {currency_code}")) iso::find(currency_code).ok_or_else(|| format!("Unknown ISO-4217 currency: {currency_code}"))
} }
/// Returns every currency accepted by [`require_iso_currency_code`], ordered by
/// its canonical alphabetic code.
pub fn iso_currency_codes() -> Vec<&'static str> {
let mut currencies = Vec::new();
for first in b'A'..=b'Z' {
for second in b'A'..=b'Z' {
for third in b'A'..=b'Z' {
let bytes = [first, second, third];
let code = std::str::from_utf8(&bytes).expect("uppercase ASCII currency code");
if let Some(currency) = iso::find(code) {
currencies.push(currency.iso_alpha_code);
}
}
}
}
currencies
}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;

Binary file not shown.

View File

@@ -734,6 +734,10 @@ pub struct ListColumnTypesResponse {
/// Every column type, declarable or not, ordered by name. /// Every column type, declarable or not, ordered by name.
#[prost(message, repeated, tag = "1")] #[prost(message, repeated, tag = "1")]
pub column_types: ::prost::alloc::vec::Vec<list_column_types_response::ColumnType>, pub column_types: ::prost::alloc::vec::Vec<list_column_types_response::ColumnType>,
/// Every canonical ISO-4217 code accepted by currency-bearing columns and
/// profile accounting settings, ordered alphabetically.
#[prost(string, repeated, tag = "2")]
pub currency_codes: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
} }
/// Nested message and enum types in `ListColumnTypesResponse`. /// Nested message and enum types in `ListColumnTypesResponse`.
pub mod list_column_types_response { pub mod list_column_types_response {