Struct Transaction
pub struct Transaction { /* private fields */ }Expand description
A generic financial transaction.
Implementations§
§impl Transaction
impl Transaction
pub const fn new(
id: TransactionId,
amount: Amount,
transaction_date: TransactionDate,
direction: TransactionDirection,
) -> Transaction
pub const fn new( id: TransactionId, amount: Amount, transaction_date: TransactionDate, direction: TransactionDirection, ) -> Transaction
Creates a pending transaction from required fields.
pub const fn id(&self) -> &TransactionId
pub const fn id(&self) -> &TransactionId
Returns the transaction identifier.
pub const fn transaction_date(&self) -> &TransactionDate
pub const fn transaction_date(&self) -> &TransactionDate
Returns the transaction date.
pub const fn posted_date(&self) -> Option<&PostedDate>
pub const fn posted_date(&self) -> Option<&PostedDate>
Returns the posted date.
pub const fn effective_date(&self) -> Option<&EffectiveDate>
pub const fn effective_date(&self) -> Option<&EffectiveDate>
Returns the effective date.
pub const fn status(&self) -> TransactionStatus
pub const fn status(&self) -> TransactionStatus
Returns the transaction status.
pub const fn direction(&self) -> TransactionDirection
pub const fn direction(&self) -> TransactionDirection
Returns the transaction direction.
pub fn description(&self) -> Option<&str>
pub fn description(&self) -> Option<&str>
Returns the optional transaction description.
pub const fn with_status(self, status: TransactionStatus) -> Transaction
pub const fn with_status(self, status: TransactionStatus) -> Transaction
Sets the transaction status.
pub fn with_posted_date(self, posted_date: PostedDate) -> Transaction
pub fn with_posted_date(self, posted_date: PostedDate) -> Transaction
Sets the posted date.
pub fn with_effective_date(self, effective_date: EffectiveDate) -> Transaction
pub fn with_effective_date(self, effective_date: EffectiveDate) -> Transaction
Sets the effective date.
pub fn with_description(
self,
description: impl AsRef<str>,
) -> Result<Transaction, TransactionError>
pub fn with_description( self, description: impl AsRef<str>, ) -> Result<Transaction, TransactionError>
Sets a non-empty transaction description.
§Errors
Returns [TransactionError::EmptyDescription] when the trimmed input is empty.
Trait Implementations§
§impl Clone for Transaction
impl Clone for Transaction
§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 more§impl Debug for Transaction
impl Debug for Transaction
§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