Struct beancount_parser_2::Transaction
source · #[non_exhaustive]pub struct Transaction<S, D> {
pub flag: Option<Flag>,
pub payee: Option<S>,
pub narration: Option<S>,
pub tags: HashSet<S>,
pub postings: Vec<Posting<S, D>>,
}
Expand description
A transaction
It notably contains a list of Posting
Example
let input = r#"
2022-05-22 * "Grocery store" "Grocery shopping" #food
Assets:Cash -10 CHF
Expenses:Groceries
"#;
let beancount = beancount_parser_2::parse::<&str, f64>(input).unwrap();
let DirectiveContent::Transaction(trx) = &beancount.directives[0].content else {
unreachable!("was not a transaction")
};
assert_eq!(trx.flag, Some(Flag::Completed));
assert_eq!(trx.payee, Some("Grocery store"));
assert_eq!(trx.narration, Some("Grocery shopping"));
assert!(trx.tags.contains("food"));
assert_eq!(trx.postings.len(), 2);
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.flag: Option<Flag>
Transaction flag (*
or !
or None
when using the txn
keyword)
payee: Option<S>
Payee (if present)
narration: Option<S>
Narration (if present)
Set of tags
postings: Vec<Posting<S, D>>
Postings
Trait Implementations§
Auto Trait Implementations§
impl<S, D> RefUnwindSafe for Transaction<S, D>where D: RefUnwindSafe, S: RefUnwindSafe,
impl<S, D> Send for Transaction<S, D>where D: Send, S: Send,
impl<S, D> Sync for Transaction<S, D>where D: Sync, S: Sync,
impl<S, D> Unpin for Transaction<S, D>where D: Unpin, S: Unpin,
impl<S, D> UnwindSafe for Transaction<S, D>where D: UnwindSafe, S: UnwindSafe,
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