pub struct Transaction { /* private fields */ }Expand description
A generic financial transaction.
Implementations§
Source§impl Transaction
impl Transaction
Sourcepub const fn new(
id: TransactionId,
amount: Amount,
transaction_date: TransactionDate,
direction: TransactionDirection,
) -> Self
pub const fn new( id: TransactionId, amount: Amount, transaction_date: TransactionDate, direction: TransactionDirection, ) -> Self
Creates a pending transaction from required fields.
Sourcepub const fn id(&self) -> &TransactionId
pub const fn id(&self) -> &TransactionId
Returns the transaction identifier.
Sourcepub const fn transaction_date(&self) -> &TransactionDate
pub const fn transaction_date(&self) -> &TransactionDate
Returns the transaction date.
Sourcepub const fn posted_date(&self) -> Option<&PostedDate>
pub const fn posted_date(&self) -> Option<&PostedDate>
Returns the posted date.
Sourcepub const fn effective_date(&self) -> Option<&EffectiveDate>
pub const fn effective_date(&self) -> Option<&EffectiveDate>
Returns the effective date.
Sourcepub const fn status(&self) -> TransactionStatus
pub const fn status(&self) -> TransactionStatus
Returns the transaction status.
Sourcepub const fn direction(&self) -> TransactionDirection
pub const fn direction(&self) -> TransactionDirection
Returns the transaction direction.
Sourcepub fn description(&self) -> Option<&str>
pub fn description(&self) -> Option<&str>
Returns the optional transaction description.
Sourcepub const fn with_status(self, status: TransactionStatus) -> Self
pub const fn with_status(self, status: TransactionStatus) -> Self
Sets the transaction status.
Sourcepub fn with_posted_date(self, posted_date: PostedDate) -> Self
pub fn with_posted_date(self, posted_date: PostedDate) -> Self
Sets the posted date.
Sourcepub fn with_effective_date(self, effective_date: EffectiveDate) -> Self
pub fn with_effective_date(self, effective_date: EffectiveDate) -> Self
Sets the effective date.
Sourcepub fn with_description(
self,
description: impl AsRef<str>,
) -> Result<Self, TransactionError>
pub fn with_description( self, description: impl AsRef<str>, ) -> Result<Self, TransactionError>
Sets a non-empty transaction description.
§Errors
Returns TransactionError::EmptyDescription when the trimmed input is empty.
Trait Implementations§
Source§impl Clone for Transaction
impl Clone for Transaction
Source§fn clone(&self) -> Transaction
fn clone(&self) -> Transaction
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Transaction
impl Debug for Transaction
Source§impl PartialEq for Transaction
impl PartialEq for Transaction
impl Eq for Transaction
impl StructuralPartialEq for Transaction
Auto Trait Implementations§
impl Freeze for Transaction
impl RefUnwindSafe for Transaction
impl Send for Transaction
impl Sync for Transaction
impl Unpin for Transaction
impl UnsafeUnpin for Transaction
impl UnwindSafe for Transaction
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more