pub struct Posting {
pub account: InternedStr,
pub units: Option<IncompleteAmount>,
pub cost: Option<CostSpec>,
pub price: Option<PriceAnnotation>,
pub flag: Option<char>,
pub meta: Metadata,
}Expand description
A posting within a transaction.
Postings represent the individual legs of a transaction. Each posting specifies an account and optionally an amount, cost, and price.
When the units are None, the entire amount will be inferred by the
interpolation algorithm to balance the transaction. When units is
Some(IncompleteAmount), it may still have missing components that
need to be filled in.
Fields§
§account: InternedStrThe account for this posting
units: Option<IncompleteAmount>The units (may be incomplete or None for auto-calculated postings)
cost: Option<CostSpec>Cost specification for the position
price: Option<PriceAnnotation>Price annotation (@ or @@)
flag: Option<char>Whether this posting has the “!” flag
meta: MetadataPosting metadata
Implementations§
Source§impl Posting
impl Posting
Sourcepub fn new(account: impl Into<InternedStr>, units: Amount) -> Self
pub fn new(account: impl Into<InternedStr>, units: Amount) -> Self
Create a new posting with the given account and complete units.
Sourcepub fn with_incomplete(
account: impl Into<InternedStr>,
units: IncompleteAmount,
) -> Self
pub fn with_incomplete( account: impl Into<InternedStr>, units: IncompleteAmount, ) -> Self
Create a new posting with an incomplete amount.
Sourcepub fn auto(account: impl Into<InternedStr>) -> Self
pub fn auto(account: impl Into<InternedStr>) -> Self
Create a posting without any amount (to be fully interpolated).
Sourcepub fn with_price(self, price: PriceAnnotation) -> Self
pub fn with_price(self, price: PriceAnnotation) -> Self
Add a price annotation.
Trait Implementations§
Source§impl Archive for Postingwhere
AsInternedStr: ArchiveWith<InternedStr>,
Option<IncompleteAmount>: Archive,
Option<CostSpec>: Archive,
Option<PriceAnnotation>: Archive,
Option<char>: Archive,
Metadata: Archive,
impl Archive for Postingwhere
AsInternedStr: ArchiveWith<InternedStr>,
Option<IncompleteAmount>: Archive,
Option<CostSpec>: Archive,
Option<PriceAnnotation>: Archive,
Option<char>: Archive,
Metadata: Archive,
Source§type Archived = ArchivedPosting
type Archived = ArchivedPosting
Source§type Resolver = PostingResolver
type Resolver = PostingResolver
Source§fn resolve(&self, resolver: Self::Resolver, out: Place<Self::Archived>)
fn resolve(&self, resolver: Self::Resolver, out: Place<Self::Archived>)
Source§const COPY_OPTIMIZATION: CopyOptimization<Self> = _
const COPY_OPTIMIZATION: CopyOptimization<Self> = _
serialize. Read moreSource§impl<'de> Deserialize<'de> for Posting
impl<'de> Deserialize<'de> for Posting
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<__D: Fallible + ?Sized> Deserialize<Posting, __D> for Archived<Posting>where
AsInternedStr: ArchiveWith<InternedStr> + DeserializeWith<<AsInternedStr as ArchiveWith<InternedStr>>::Archived, InternedStr, __D>,
Option<IncompleteAmount>: Archive,
<Option<IncompleteAmount> as Archive>::Archived: Deserialize<Option<IncompleteAmount>, __D>,
Option<CostSpec>: Archive,
<Option<CostSpec> as Archive>::Archived: Deserialize<Option<CostSpec>, __D>,
Option<PriceAnnotation>: Archive,
<Option<PriceAnnotation> as Archive>::Archived: Deserialize<Option<PriceAnnotation>, __D>,
Option<char>: Archive,
<Option<char> as Archive>::Archived: Deserialize<Option<char>, __D>,
Metadata: Archive,
<Metadata as Archive>::Archived: Deserialize<Metadata, __D>,
impl<__D: Fallible + ?Sized> Deserialize<Posting, __D> for Archived<Posting>where
AsInternedStr: ArchiveWith<InternedStr> + DeserializeWith<<AsInternedStr as ArchiveWith<InternedStr>>::Archived, InternedStr, __D>,
Option<IncompleteAmount>: Archive,
<Option<IncompleteAmount> as Archive>::Archived: Deserialize<Option<IncompleteAmount>, __D>,
Option<CostSpec>: Archive,
<Option<CostSpec> as Archive>::Archived: Deserialize<Option<CostSpec>, __D>,
Option<PriceAnnotation>: Archive,
<Option<PriceAnnotation> as Archive>::Archived: Deserialize<Option<PriceAnnotation>, __D>,
Option<char>: Archive,
<Option<char> as Archive>::Archived: Deserialize<Option<char>, __D>,
Metadata: Archive,
<Metadata as Archive>::Archived: Deserialize<Metadata, __D>,
Source§impl<__S: Fallible + ?Sized> Serialize<__S> for Postingwhere
AsInternedStr: SerializeWith<InternedStr, __S>,
Option<IncompleteAmount>: Serialize<__S>,
Option<CostSpec>: Serialize<__S>,
Option<PriceAnnotation>: Serialize<__S>,
Option<char>: Serialize<__S>,
Metadata: Serialize<__S>,
impl<__S: Fallible + ?Sized> Serialize<__S> for Postingwhere
AsInternedStr: SerializeWith<InternedStr, __S>,
Option<IncompleteAmount>: Serialize<__S>,
Option<CostSpec>: Serialize<__S>,
Option<PriceAnnotation>: Serialize<__S>,
Option<char>: Serialize<__S>,
Metadata: Serialize<__S>,
impl Eq for Posting
impl StructuralPartialEq for Posting
Auto Trait Implementations§
impl Freeze for Posting
impl RefUnwindSafe for Posting
impl Send for Posting
impl Sync for Posting
impl Unpin for Posting
impl UnwindSafe for Posting
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> ArchiveUnsized for Twhere
T: Archive,
impl<T> ArchiveUnsized for Twhere
T: Archive,
Source§type Archived = <T as Archive>::Archived
type Archived = <T as Archive>::Archived
Archive, it may be
unsized. Read moreSource§fn archived_metadata(
&self,
) -> <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata
fn archived_metadata( &self, ) -> <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.