pub enum AssetCapacity {
Continuous(Capacity),
Discrete(u32, Capacity),
}Expand description
Capacity of an asset, which may be continuous or a discrete number of indivisible units
Variants§
Continuous(Capacity)
Continuous capacity
Discrete(u32, Capacity)
Discrete capacity represented by a number of indivisible units Stores: (number of units, unit size)
Implementations§
Source§impl AssetCapacity
impl AssetCapacity
Sourcefn check_same_unit_size(size1: Capacity, size2: Capacity)
fn check_same_unit_size(size1: Capacity, size2: Capacity)
Validates that two discrete capacities have the same unit size.
Sourcepub fn from_capacity(capacity: Capacity, unit_size: Option<Capacity>) -> Self
pub fn from_capacity(capacity: Capacity, unit_size: Option<Capacity>) -> Self
Create an AssetCapacity from a total capacity and optional unit size
If a unit size is provided, the capacity is represented as a discrete number of units,
calculated as the ceiling of (capacity / unit_size). If no unit size is provided, the
capacity is represented as continuous.
Sourcepub fn total_capacity(&self) -> Capacity
pub fn total_capacity(&self) -> Capacity
Returns the total capacity represented by this AssetCapacity.
Sourcepub fn n_units(&self) -> Option<u32>
pub fn n_units(&self) -> Option<u32>
Returns the number of units if this is a discrete capacity, or None if continuous.
Sourcepub fn assert_same_type(&self, other: AssetCapacity)
pub fn assert_same_type(&self, other: AssetCapacity)
Asserts that both capacities are the same type (both continuous or both discrete).
Sourcepub fn apply_limit_factor(self, limit_factor: Dimensionless) -> Self
pub fn apply_limit_factor(self, limit_factor: Dimensionless) -> Self
Applies a limit factor to the capacity, scaling it accordingly.
For discrete capacities, the number of units is scaled by the limit factor and rounded up to the nearest integer.
Trait Implementations§
Source§impl Add for AssetCapacity
impl Add for AssetCapacity
Source§type Output = AssetCapacity
type Output = AssetCapacity
+ operator.Source§fn add(self, rhs: AssetCapacity) -> Self
fn add(self, rhs: AssetCapacity) -> Self
+ operation. Read moreSource§impl Clone for AssetCapacity
impl Clone for AssetCapacity
Source§fn clone(&self) -> AssetCapacity
fn clone(&self) -> AssetCapacity
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AssetCapacity
impl Debug for AssetCapacity
Source§impl Ord for AssetCapacity
impl Ord for AssetCapacity
Source§impl PartialEq for AssetCapacity
impl PartialEq for AssetCapacity
Source§impl PartialOrd for AssetCapacity
impl PartialOrd for AssetCapacity
Source§impl Sub for AssetCapacity
impl Sub for AssetCapacity
Source§type Output = AssetCapacity
type Output = AssetCapacity
- operator.Source§fn sub(self, rhs: AssetCapacity) -> Self
fn sub(self, rhs: AssetCapacity) -> Self
- operation. Read moreimpl Copy for AssetCapacity
impl Eq for AssetCapacity
impl StructuralPartialEq for AssetCapacity
Auto Trait Implementations§
impl Freeze for AssetCapacity
impl RefUnwindSafe for AssetCapacity
impl Send for AssetCapacity
impl Sync for AssetCapacity
impl Unpin for AssetCapacity
impl UnwindSafe for AssetCapacity
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
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>
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>
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