Struct fedimint_core::tiered_multi::TieredMulti
source · pub struct TieredMulti<T>(/* private fields */);
Expand description
Represents notes of different denominations.
Attention: care has to be taken when constructing this to avoid overflow when calculating the total amount represented. As it is prudent to limit both the maximum note amount and maximum note count per transaction this shouldn’t be a problem in practice though.
Implementations§
source§impl<T> TieredMulti<T>
impl<T> TieredMulti<T>
sourcepub fn new(map: BTreeMap<Amount, Vec<T>>) -> Self
pub fn new(map: BTreeMap<Amount, Vec<T>>) -> Self
Returns a new TieredMulti
with the given BTreeMap
map
sourcepub fn total_amount(&self) -> Amount
pub fn total_amount(&self) -> Amount
Returns the total value of all notes in msat as Amount
sourcepub fn count_items(&self) -> usize
pub fn count_items(&self) -> usize
Returns the number of items in all vectors
sourcepub fn count_tiers(&self) -> usize
pub fn count_tiers(&self) -> usize
Returns the number of tiers
sourcepub fn iter_tiers(&self) -> impl Iterator<Item = &Amount>
pub fn iter_tiers(&self) -> impl Iterator<Item = &Amount>
Returns an iterator over the keys
sourcepub fn summary(&self) -> TieredSummary
pub fn summary(&self) -> TieredSummary
Returns the summary of number of items in each tier
sourcepub fn structural_eq<O>(&self, other: &TieredMulti<O>) -> bool
pub fn structural_eq<O>(&self, other: &TieredMulti<O>) -> bool
Verifies whether the structure of self
and other
is identical
sourcepub fn iter_items(
&self
) -> impl Iterator<Item = (Amount, &T)> + DoubleEndedIterator
pub fn iter_items( &self ) -> impl Iterator<Item = (Amount, &T)> + DoubleEndedIterator
Returns an iterator over every (Amount, &T)
Note: The order of the elements is important: from the lowest tier to the highest, then in order of elements in the Vec
sourcepub fn into_iter_items(
self
) -> impl Iterator<Item = (Amount, T)> + DoubleEndedIterator
pub fn into_iter_items( self ) -> impl Iterator<Item = (Amount, T)> + DoubleEndedIterator
Returns an consuming iterator over every (Amount, T)
Note: The order of the elements is important: from the lowest tier to the highest, then in order of elements in the Vec
sourcepub fn longest_tier_except(&self, except: &Amount) -> usize
pub fn longest_tier_except(&self, except: &Amount) -> usize
Returns the length of the longest vector of all tiers, ignoring the
except
tier
sourcepub fn all_tiers_exist_in<K>(
&self,
keys: &Tiered<K>
) -> Result<(), InvalidAmountTierError>
pub fn all_tiers_exist_in<K>( &self, keys: &Tiered<K> ) -> Result<(), InvalidAmountTierError>
Verifies that all keys in self
are present in the keys of the given
parameter Tiered
sourcepub fn get(&self, amt: Amount) -> Option<&Vec<T>>
pub fn get(&self, amt: Amount) -> Option<&Vec<T>>
Returns an Option
with a reference to the vector of the given Amount
pub fn get_mut(&mut self, amt: Amount) -> Option<&mut Vec<T>>
Trait Implementations§
source§impl<T: Clone> Clone for TieredMulti<T>
impl<T: Clone> Clone for TieredMulti<T>
source§fn clone(&self) -> TieredMulti<T>
fn clone(&self) -> TieredMulti<T>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<T: Debug> Debug for TieredMulti<T>
impl<T: Debug> Debug for TieredMulti<T>
source§impl<C> Decodable for TieredMulti<C>where
C: Decodable,
impl<C> Decodable for TieredMulti<C>where
C: Decodable,
source§fn consensus_decode<D: Read>(
d: &mut D,
modules: &ModuleDecoderRegistry
) -> Result<Self, DecodeError>
fn consensus_decode<D: Read>( d: &mut D, modules: &ModuleDecoderRegistry ) -> Result<Self, DecodeError>
source§fn consensus_decode_hex(
hex: &str,
modules: &ModuleDecoderRegistry
) -> Result<Self, DecodeError>
fn consensus_decode_hex( hex: &str, modules: &ModuleDecoderRegistry ) -> Result<Self, DecodeError>
source§impl<C> Default for TieredMulti<C>
impl<C> Default for TieredMulti<C>
source§impl<'de, T> Deserialize<'de> for TieredMulti<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for TieredMulti<T>where
T: Deserialize<'de>,
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<C> Encodable for TieredMulti<C>where
C: Encodable,
impl<C> Encodable for TieredMulti<C>where
C: Encodable,
source§fn consensus_encode<W: Write>(&self, writer: &mut W) -> Result<usize, Error>
fn consensus_encode<W: Write>(&self, writer: &mut W) -> Result<usize, Error>
source§fn consensus_encode_to_vec(&self) -> Result<Vec<u8>, Error>
fn consensus_encode_to_vec(&self) -> Result<Vec<u8>, Error>
Self::consensus_encode
to newly allocated Vec<u8>
fn consensus_encode_to_hex(&self) -> Result<String, Error>
source§impl<C> Extend<(Amount, C)> for TieredMulti<C>
impl<C> Extend<(Amount, C)> for TieredMulti<C>
source§fn extend<T: IntoIterator<Item = (Amount, C)>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = (Amount, C)>>(&mut self, iter: T)
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)source§impl<C> FromIterator<(Amount, C)> for TieredMulti<C>
impl<C> FromIterator<(Amount, C)> for TieredMulti<C>
source§impl<T: Hash> Hash for TieredMulti<T>
impl<T: Hash> Hash for TieredMulti<T>
source§impl<C> IntoIterator for TieredMulti<C>where
C: 'static + Send,
impl<C> IntoIterator for TieredMulti<C>where
C: 'static + Send,
source§impl<T: PartialEq> PartialEq for TieredMulti<T>
impl<T: PartialEq> PartialEq for TieredMulti<T>
source§fn eq(&self, other: &TieredMulti<T>) -> bool
fn eq(&self, other: &TieredMulti<T>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<T> Serialize for TieredMulti<T>where
T: Serialize,
impl<T> Serialize for TieredMulti<T>where
T: Serialize,
impl<T: Eq> Eq for TieredMulti<T>
impl<T> StructuralEq for TieredMulti<T>
impl<T> StructuralPartialEq for TieredMulti<T>
Auto Trait Implementations§
impl<T> RefUnwindSafe for TieredMulti<T>where
T: RefUnwindSafe,
impl<T> Send for TieredMulti<T>where
T: Send,
impl<T> Sync for TieredMulti<T>where
T: Sync,
impl<T> Unpin for TieredMulti<T>
impl<T> UnwindSafe for TieredMulti<T>where
T: RefUnwindSafe,
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
§impl<T> Conv for T
impl<T> Conv for T
source§impl<T> DatabaseValue for T
impl<T> DatabaseValue for T
fn from_bytes( data: &[u8], modules: &ModuleRegistry<Decoder, DecodingMode> ) -> Result<T, DecodingError>
fn to_bytes(&self) -> Vec<u8> ⓘ
source§impl<T> DynEncodable for Twhere
T: Encodable,
impl<T> DynEncodable for Twhere
T: Encodable,
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
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>
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.source§impl<T> Serialize for T
impl<T> Serialize for T
fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<Ok, Error>
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.