#[repr(transparent)]pub struct BlockAccessIndex(pub u64);Expand description
Block access index within a block.
A block’s indices are laid out as:
0— pre-execution (system contract calls, block-level setup, …)1..=tx_len— transaction execution (transaction indeximaps to indexi + 1)tx_len + 1— post-execution (block rewards, withdrawals, …)
Stored as a u64 internally, but wrapped as a newtype so it cannot be accidentally
confused with other u64 indices (for example, an account_id passed alongside it).
RLP, borsh, and arbitrary representations are identical to the wrapped u64. Serde
serializes as a hex "quantity" string (e.g. "0x1a"), matching the previous
BlockAccessIndex = u64 alias behavior when paired with the crate::quantity module.
Tuple Fields§
§0: u64Implementations§
Source§impl BlockAccessIndex
impl BlockAccessIndex
Sourcepub const PRE_EXECUTION: BlockAccessIndex
pub const PRE_EXECUTION: BlockAccessIndex
Pre-execution slot (index 0).
Sourcepub const fn new(value: u64) -> BlockAccessIndex
pub const fn new(value: u64) -> BlockAccessIndex
Constructs a new BlockAccessIndex from a raw u64.
Sourcepub const fn from_tx_index(tx_index: u64) -> BlockAccessIndex
pub const fn from_tx_index(tx_index: u64) -> BlockAccessIndex
Constructs a new BlockAccessIndex from a 0-based transaction index.
Transaction changes start at index 1 in a block access list, so transaction
index 0 maps to block access index 1.
Sourcepub const fn phase(self, tx_len: usize) -> Option<BlockAccessPhase>
pub const fn phase(self, tx_len: usize) -> Option<BlockAccessPhase>
Classifies this index into a BlockAccessPhase, given the number of transactions
in the block.
Returns:
Some(BlockAccessPhase::PreExecution)when the index is0.Some(BlockAccessPhase::Transaction(i))when the index is in1..=tx_len, withi = index - 1as a 0-based transaction index.Some(BlockAccessPhase::PostExecution)when the index is exactlytx_len + 1.Nonewhen the index is strictly greater thantx_len + 1(out of range for a block withtx_lentransactions).
Trait Implementations§
Source§impl<'arbitrary> Arbitrary<'arbitrary> for BlockAccessIndex
impl<'arbitrary> Arbitrary<'arbitrary> for BlockAccessIndex
Source§fn arbitrary(
u: &mut Unstructured<'arbitrary>,
) -> Result<BlockAccessIndex, Error>
fn arbitrary( u: &mut Unstructured<'arbitrary>, ) -> Result<BlockAccessIndex, Error>
Self from the given unstructured data. Read moreSource§fn arbitrary_take_rest(
u: Unstructured<'arbitrary>,
) -> Result<BlockAccessIndex, Error>
fn arbitrary_take_rest( u: Unstructured<'arbitrary>, ) -> Result<BlockAccessIndex, Error>
Self from the entirety of the given
unstructured data. Read moreSource§fn size_hint(depth: usize) -> (usize, Option<usize>)
fn size_hint(depth: usize) -> (usize, Option<usize>)
Unstructured this type
needs to construct itself. Read moreSource§fn try_size_hint(
depth: usize,
) -> Result<(usize, Option<usize>), MaxRecursionReached>
fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>
Unstructured this type
needs to construct itself. Read moreSource§impl Clone for BlockAccessIndex
impl Clone for BlockAccessIndex
Source§fn clone(&self) -> BlockAccessIndex
fn clone(&self) -> BlockAccessIndex
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for BlockAccessIndex
Source§impl Debug for BlockAccessIndex
impl Debug for BlockAccessIndex
Source§impl Decodable for BlockAccessIndex
impl Decodable for BlockAccessIndex
Source§impl Default for BlockAccessIndex
impl Default for BlockAccessIndex
Source§fn default() -> BlockAccessIndex
fn default() -> BlockAccessIndex
Source§impl<'de> Deserialize<'de> for BlockAccessIndex
Available on crate feature serde only.
impl<'de> Deserialize<'de> for BlockAccessIndex
serde only.Source§fn deserialize<D>(
deserializer: D,
) -> Result<BlockAccessIndex, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<BlockAccessIndex, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl Display for BlockAccessIndex
impl Display for BlockAccessIndex
Source§impl Encodable for BlockAccessIndex
impl Encodable for BlockAccessIndex
impl Eq for BlockAccessIndex
Source§impl Hash for BlockAccessIndex
impl Hash for BlockAccessIndex
Source§impl LowerHex for BlockAccessIndex
impl LowerHex for BlockAccessIndex
Source§impl Ord for BlockAccessIndex
impl Ord for BlockAccessIndex
Source§fn cmp(&self, other: &BlockAccessIndex) -> Ordering
fn cmp(&self, other: &BlockAccessIndex) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for BlockAccessIndex
impl PartialEq for BlockAccessIndex
Source§fn eq(&self, other: &BlockAccessIndex) -> bool
fn eq(&self, other: &BlockAccessIndex) -> bool
self and other values to be equal, and is used by ==.Source§impl PartialOrd for BlockAccessIndex
impl PartialOrd for BlockAccessIndex
Source§impl Serialize for BlockAccessIndex
Available on crate feature serde only.
impl Serialize for BlockAccessIndex
serde only.Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
impl StructuralPartialEq for BlockAccessIndex
Auto Trait Implementations§
impl Freeze for BlockAccessIndex
impl RefUnwindSafe for BlockAccessIndex
impl Send for BlockAccessIndex
impl Sync for BlockAccessIndex
impl Unpin for BlockAccessIndex
impl UnsafeUnpin for BlockAccessIndex
impl UnwindSafe for BlockAccessIndex
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<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§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 moreLayout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 8 bytes