pub struct Weight(_);Expand description
Represents block weight - the weight of a transaction or block.
This is an integer newtype representing weigth in wu. It provides protection against mixing
up the types as well as basic formatting features.
Implementations§
§impl Weight
impl Weight
pub const ZERO: Weight = Weight(0)
pub const ZERO: Weight = Weight(0)
0 wu.
Equivalent to MIN, may better express intent in some contexts.
pub const MIN: Weight = Weight(u64::min_value())
pub const MIN: Weight = Weight(u64::min_value())
Minimum possible value (0 wu).
Equivalent to ZERO, may better express intent in some contexts.
pub const fn from_vb_unchecked(vb: u64) -> Weight
pub const fn from_vb_unchecked(vb: u64) -> Weight
Constructs Weight from virtual bytes without overflow check.
pub const fn from_witness_data_size(witness_size: u64) -> Weight
pub const fn from_witness_data_size(witness_size: u64) -> Weight
Constructs Weight from witness size.
pub const fn from_non_witness_data_size(non_witness_size: u64) -> Weight
pub const fn from_non_witness_data_size(non_witness_size: u64) -> Weight
Constructs Weight from non-witness size.
pub const fn to_wu(self) -> u64
pub const fn to_wu(self) -> u64
Returns raw weight units.
Can be used instead of into() to avoid inference issues.
pub const fn to_vbytes_floor(self) -> u64
pub const fn to_vbytes_floor(self) -> u64
Converts to vB rounding down.
pub const fn to_vbytes_ceil(self) -> u64
pub const fn to_vbytes_ceil(self) -> u64
Converts to vB rounding up.
pub fn checked_add(self, rhs: Weight) -> Option<Weight>
pub fn checked_add(self, rhs: Weight) -> Option<Weight>
Checked addition.
Computes self + rhs returning None if overflow occurred.
pub fn checked_sub(self, rhs: Weight) -> Option<Weight>
pub fn checked_sub(self, rhs: Weight) -> Option<Weight>
Checked subtraction.
Computes self - rhs returning None if overflow occurred.
pub fn checked_mul(self, rhs: u64) -> Option<Weight>
pub fn checked_mul(self, rhs: u64) -> Option<Weight>
Checked multiplication.
Computes self * rhs returning None if overflow occurred.
pub fn checked_div(self, rhs: u64) -> Option<Weight>
pub fn checked_div(self, rhs: u64) -> Option<Weight>
Checked division.
Computes self / rhs returning None if rhs == 0.
Trait Implementations§
§impl AddAssign<Weight> for Weight
impl AddAssign<Weight> for Weight
§fn add_assign(&mut self, rhs: Weight)
fn add_assign(&mut self, rhs: Weight)
+= operation. Read more§impl DivAssign<u64> for Weight
impl DivAssign<u64> for Weight
§fn div_assign(&mut self, rhs: u64)
fn div_assign(&mut self, rhs: u64)
/= operation. Read more§impl MulAssign<u64> for Weight
impl MulAssign<u64> for Weight
§fn mul_assign(&mut self, rhs: u64)
fn mul_assign(&mut self, rhs: u64)
*= operation. Read more§impl Ord for Weight
impl Ord for Weight
§impl PartialOrd<Weight> for Weight
impl PartialOrd<Weight> for Weight
§fn partial_cmp(&self, other: &Weight) -> Option<Ordering>
fn partial_cmp(&self, other: &Weight) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read more§impl SubAssign<Weight> for Weight
impl SubAssign<Weight> for Weight
§fn sub_assign(&mut self, rhs: Weight)
fn sub_assign(&mut self, rhs: Weight)
-= operation. Read moreimpl Copy for Weight
impl Eq for Weight
impl StructuralEq for Weight
impl StructuralPartialEq for Weight
Auto Trait Implementations§
impl RefUnwindSafe for Weight
impl Send for Weight
impl Sync for Weight
impl Unpin for Weight
impl UnwindSafe for Weight
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<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.