pub struct Spayd { /* private fields */ }
Expand description
A Short Payment Descriptor structure containint the details of a requested payment.
Implementations§
source§impl Spayd
impl Spayd
sourcepub fn account(&self) -> Result<IbanBic, SpaydError>
pub fn account(&self) -> Result<IbanBic, SpaydError>
Get the account number as a separated IBAN and BIC
sourcepub fn set_account<T>(&mut self, account: T)
pub fn set_account<T>(&mut self, account: T)
Set the account IBAN from an IBAN and BIC
sourcepub fn alternative_accounts(&self) -> Result<Vec<IbanBic>, SpaydError>
pub fn alternative_accounts(&self) -> Result<Vec<IbanBic>, SpaydError>
Get alternative account numbers
sourcepub fn set_alternative_accounts<I, T>(&mut self, accounts: I)
pub fn set_alternative_accounts<I, T>(&mut self, accounts: I)
Set alternative account numbers
sourcepub fn due_date(&self) -> Result<NaiveDate, SpaydError>
pub fn due_date(&self) -> Result<NaiveDate, SpaydError>
Get the due date as a Chrono NaiveDate
sourcepub fn set_due_date(&mut self, date: &NaiveDate)
pub fn set_due_date(&mut self, date: &NaiveDate)
Set the due date from a Chrono NaiveDate
sourcepub fn amount(&self) -> Result<Decimal, SpaydError>
pub fn amount(&self) -> Result<Decimal, SpaydError>
Get the payment amount as a decimal
sourcepub fn set_amount(&mut self, amount: &Decimal)
pub fn set_amount(&mut self, amount: &Decimal)
Set the due date from a decimal
sourcepub fn currency(&self) -> Result<Currency, SpaydError>
pub fn currency(&self) -> Result<Currency, SpaydError>
Get the currency as an ISO currency
sourcepub fn set_currency(&mut self, currency: Currency)
pub fn set_currency(&mut self, currency: Currency)
Set the currency using an ISO currency
source§impl Spayd
impl Spayd
sourcepub fn check_crc32(&self) -> Crc32Result
pub fn check_crc32(&self) -> Crc32Result
Perform a CRC32 integrity check on the SPAYD to help ensure that it was received correctly. This check does not provide any assurance of the authenticity of the SPAYD value or any other form of cryptographic security.
As the CRC32 field is optional, this will report success when the field is not supplied. To enforce the usage of CRC32 use require_crc32.
sourcepub fn require_crc32(&self) -> Crc32Result
pub fn require_crc32(&self) -> Crc32Result
Ensure that a CRC32 checksum is present and check that the SPAYD matches it.
source§impl<'a> Spayd
impl<'a> Spayd
sourcepub fn new<I, K, V>(version: SpaydVersion, fields: I) -> Self
pub fn new<I, K, V>(version: SpaydVersion, fields: I) -> Self
Create a new SPAYD with the given version number and field values.
Using new_v1_0
or empty_v1_0
is preferable for most situations.
sourcepub fn new_v1_0<I, K, V>(fields: I) -> Self
pub fn new_v1_0<I, K, V>(fields: I) -> Self
Create a version 1.0 SPAYD with the given field values.
sourcepub fn empty_v1_0() -> Self
pub fn empty_v1_0() -> Self
Create an empty version 1.0 SPAYD.
sourcepub fn version(&self) -> SpaydVersion
pub fn version(&self) -> SpaydVersion
Get the version number.
sourcepub fn validate(&self) -> Result<(), SpaydError>
pub fn validate(&self) -> Result<(), SpaydError>
Ensure that the SPAYD has all required fields and that the CRC check is correct (if this feature is enabled).
sourcepub fn iter(&self) -> impl Iterator<Item = (&str, &str)>
pub fn iter(&self) -> impl Iterator<Item = (&str, &str)>
Iterates over the fields in the SPAYD. No particular ordering is guaranteed.
sourcepub fn iter_canonic(&self) -> impl Iterator<Item = (&str, &str)>
pub fn iter_canonic(&self) -> impl Iterator<Item = (&str, &str)>
Iterates over the fields in canonic order. The keys are alphabetical and the CRC32 field is excluded. This can be used to create a cannonical represenataion of the SPAYD which can be CRC32 checked.
sourcepub fn canonic_representation(&self) -> String
pub fn canonic_representation(&self) -> String
Construct canonic representation for CRC32 checking