pub struct TxRecord { /* private fields */ }

Implementations

Holds a transaction informations

Get the tags for the tx, sorted alphabetically

Get the amount for the tx, rounded to 2 decimals

Get the lifetime for the tx

Get the start date for the tx

Get the datetime when the tx was recorded

Get the datetime when the tx was recorded as a rfc3339 string

Returns true if the base amount is the same as the total

That is, when there is no repetition on the lifetime

Tells if the TxRecord as a tag

Returns total amount for the transaction record

Returns the duration in days for this transaction

Calculates and returns the per diem for the record and round it to the 2 decimals

Calculates and returns the per diem for the record

The per diem is calculated as follow:

  • END_DAY = START_DAY + (RECURRENCE_SIZE_DAYS * SEC_IN_DAYS * RECURRENCE_TIMES)
  • PER_DIEM = AMOUNT * RECURRENCE_TIMES) / (END_DAY - START_DAY )

Get the progress of the transaction at date

None will use today as a data

Returns the end date (always computed)

Serialize the record to its string format

Builds a TxRecord using parameters

Arguments
  • name - A string slice that holds the name of the transaction
  • tags - A vector of string slices with the transaction’s tags
  • amount - A string slice representing a monetary value
  • starts_on - The date of the start of the transaction
  • lifetime - The lifetime of transaction
  • recorded_at - The localized exact time when the tx was added
  • src - An option string slice with the original string used to submit the tx
Examples
use costoflife::{self, TxRecord, Lifetime};

let tx = TxRecord::from(
    "Car",
    vec!["transportation", "lifestyle"],
    "100000",
    costoflife::date(01, 01, 2010),
    Lifetime::Year {
        amount: 20,
        times: 1,
    },
    costoflife::now_local(),
    None,
).unwrap();

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

The associated error which can be returned from parsing.

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

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.