#[non_exhaustive]pub enum HoldStatus<const P: u8 = 2> {
Open,
Posted {
by: EntryId,
amount: Amount<P>,
},
Voided {
by: EntryId,
},
Expired {
by: EntryId,
},
}Expand description
Where a hold stands.
use doubleentry::{EntryId, HoldStatus, amount};
let by = EntryId::from_bytes([7; 16]);
let posted: HoldStatus = HoldStatus::Posted { by, amount: amount!("60.00") };
assert_eq!(posted.resolved_by(), Some(by));
assert_eq!(posted.to_string(), format!("posted 60.00 by {by}"));
assert_eq!(HoldStatus::<2>::Open.resolved_by(), None);Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Open
Not resolved yet: the amount is reserved.
Posted
Posted by an entry: amount was settled, the rest released.
Voided
Voided by an entry.
Expired
Expired by an entry.
Implementations§
Source§impl<const P: u8> HoldStatus<P>
impl<const P: u8> HoldStatus<P>
Sourcepub const fn resolved_by(&self) -> Option<EntryId>
pub const fn resolved_by(&self) -> Option<EntryId>
The entry that resolved the hold; None while open.
Trait Implementations§
Source§impl<const P: u8> Clone for HoldStatus<P>
impl<const P: u8> Clone for HoldStatus<P>
impl<const P: u8> Copy for HoldStatus<P>
Source§impl<const P: u8> Debug for HoldStatus<P>
impl<const P: u8> Debug for HoldStatus<P>
Source§impl<'de, const P: u8> Deserialize<'de> for HoldStatus<P>
Available on crate feature serde only.
impl<'de, const P: u8> Deserialize<'de> for HoldStatus<P>
Available on crate feature
serde only.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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<const P: u8> Display for HoldStatus<P>
impl<const P: u8> Display for HoldStatus<P>
impl<const P: u8> Eq for HoldStatus<P>
Source§impl<const P: u8> Hash for HoldStatus<P>
impl<const P: u8> Hash for HoldStatus<P>
Source§impl<const P: u8> PartialEq for HoldStatus<P>
impl<const P: u8> PartialEq for HoldStatus<P>
Source§impl<const P: u8> Serialize for HoldStatus<P>
Available on crate feature serde only.
impl<const P: u8> Serialize for HoldStatus<P>
Available on crate feature
serde only.impl<const P: u8> StructuralPartialEq for HoldStatus<P>
Auto Trait Implementations§
impl<const P: u8> Freeze for HoldStatus<P>
impl<const P: u8> RefUnwindSafe for HoldStatus<P>where
Amount<P>: RefUnwindSafe,
impl<const P: u8> Send for HoldStatus<P>
impl<const P: u8> Sync for HoldStatus<P>
impl<const P: u8> Unpin for HoldStatus<P>
impl<const P: u8> UnsafeUnpin for HoldStatus<P>where
Amount<P>: UnsafeUnpin,
impl<const P: u8> UnwindSafe for HoldStatus<P>where
Amount<P>: 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more