Struct spayd::Spayd

source ·
pub struct Spayd { /* private fields */ }
Expand description

A Short Payment Descriptor structure containint the details of a requested payment.

Implementations§

source§

impl Spayd

source

pub fn account(&self) -> Result<IbanBic, SpaydError>

Get the account number as a separated IBAN and BIC

source

pub fn set_account<T>(&mut self, account: T)
where T: Into<IbanBic>,

Set the account IBAN from an IBAN and BIC

source

pub fn alternative_accounts(&self) -> Result<Vec<IbanBic>, SpaydError>

Get alternative account numbers

source

pub fn set_alternative_accounts<I, T>(&mut self, accounts: I)
where I: IntoIterator<Item = T>, T: Into<IbanBic>,

Set alternative account numbers

source

pub fn due_date(&self) -> Result<NaiveDate, SpaydError>

Get the due date as a Chrono NaiveDate

source

pub fn set_due_date(&mut self, date: &NaiveDate)

Set the due date from a Chrono NaiveDate

source

pub fn amount(&self) -> Result<Decimal, SpaydError>

Get the payment amount as a decimal

source

pub fn set_amount(&mut self, amount: &Decimal)

Set the due date from a decimal

source

pub fn currency(&self) -> Result<Currency, SpaydError>

Get the currency as an ISO currency

source

pub fn set_currency(&mut self, currency: Currency)

Set the currency using an ISO currency

source§

impl Spayd

source

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.

source

pub fn require_crc32(&self) -> Crc32Result

Ensure that a CRC32 checksum is present and check that the SPAYD matches it.

source§

impl<'a> Spayd

source

pub fn new<I, K, V>(version: SpaydVersion, fields: I) -> Self
where I: IntoIterator<Item = (K, V)>, K: ToString, V: ToString,

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.

source

pub fn new_v1_0<I, K, V>(fields: I) -> Self
where I: IntoIterator<Item = (K, V)>, K: ToString, V: ToString,

Create a version 1.0 SPAYD with the given field values.

source

pub fn empty_v1_0() -> Self

Create an empty version 1.0 SPAYD.

source

pub fn version(&self) -> SpaydVersion

Get the version number.

source

pub fn field(&self, key: &str) -> Option<&str>

Get the value of the given field.

source

pub fn set_field<K, V>(&mut self, key: K, value: V)
where K: ToString, V: ToString,

Set the value of the given field.

source

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).

source

pub fn iter(&self) -> impl Iterator<Item = (&str, &str)>

Iterates over the fields in the SPAYD. No particular ordering is guaranteed.

source

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.

source

pub fn canonic_representation(&self) -> String

Construct canonic representation for CRC32 checking

Trait Implementations§

source§

impl Clone for Spayd

source§

fn clone(&self) -> Spayd

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Spayd

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Display for Spayd

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl FromStr for Spayd

§

type Err = SpaydError

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
source§

impl PartialEq for Spayd

source§

fn eq(&self, other: &Spayd) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for Spayd

source§

impl StructuralEq for Spayd

source§

impl StructuralPartialEq for Spayd

Auto Trait Implementations§

§

impl RefUnwindSafe for Spayd

§

impl Send for Spayd

§

impl Sync for Spayd

§

impl Unpin for Spayd

§

impl UnwindSafe for Spayd

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.