pub enum BlockId {
Hash(RpcBlockHash),
Number(BlockNumberOrTag),
}
Expand description
A Block Identifier. https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1898.md
Variants§
Hash(RpcBlockHash)
A block hash and an optional bool that defines if it’s canonical
Number(BlockNumberOrTag)
A block number
Implementations§
Source§impl BlockId
impl BlockId
Sourcepub const fn as_block_hash(&self) -> Option<FixedBytes<32>>
pub const fn as_block_hash(&self) -> Option<FixedBytes<32>>
Returns the block hash if it is BlockId::Hash
Sourcepub const fn as_u64(&self) -> Option<u64>
pub const fn as_u64(&self) -> Option<u64>
Returns the block number if it is BlockId::Number
and not a tag
Sourcepub const fn is_latest(&self) -> bool
pub const fn is_latest(&self) -> bool
Returns true if this is BlockNumberOrTag::Latest
Sourcepub const fn is_pending(&self) -> bool
pub const fn is_pending(&self) -> bool
Returns true if this is BlockNumberOrTag::Pending
Sourcepub const fn is_safe(&self) -> bool
pub const fn is_safe(&self) -> bool
Returns true if this is BlockNumberOrTag::Safe
Sourcepub const fn is_finalized(&self) -> bool
pub const fn is_finalized(&self) -> bool
Returns true if this is BlockNumberOrTag::Finalized
Sourcepub const fn is_earliest(&self) -> bool
pub const fn is_earliest(&self) -> bool
Returns true if this is BlockNumberOrTag::Earliest
Sourcepub const fn is_number(&self) -> bool
pub const fn is_number(&self) -> bool
Returns true if this is BlockNumberOrTag::Number
Sourcepub const fn is_hash(&self) -> bool
pub const fn is_hash(&self) -> bool
Returns true if this is BlockId::Hash
Sourcepub const fn hash(block_hash: FixedBytes<32>) -> BlockId
pub const fn hash(block_hash: FixedBytes<32>) -> BlockId
Create a new block hash instance.
Sourcepub const fn hash_canonical(block_hash: FixedBytes<32>) -> BlockId
pub const fn hash_canonical(block_hash: FixedBytes<32>) -> BlockId
Create a new block hash instance that requires the block to be canonical.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for BlockId
Available on crate feature serde
only.
impl<'de> Deserialize<'de> for BlockId
Available on crate feature
serde
only.Source§fn deserialize<D>(
deserializer: D,
) -> Result<BlockId, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<BlockId, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<BlockNumberOrTag> for BlockId
impl From<BlockNumberOrTag> for BlockId
Source§fn from(num: BlockNumberOrTag) -> BlockId
fn from(num: BlockNumberOrTag) -> BlockId
Converts to this type from the input type.
Source§impl From<FixedBytes<32>> for BlockId
impl From<FixedBytes<32>> for BlockId
Source§fn from(block_hash: FixedBytes<32>) -> BlockId
fn from(block_hash: FixedBytes<32>) -> BlockId
Converts to this type from the input type.
Source§impl From<HashOrNumber> for BlockId
impl From<HashOrNumber> for BlockId
Source§fn from(block: HashOrNumber) -> BlockId
fn from(block: HashOrNumber) -> BlockId
Converts to this type from the input type.
Source§impl From<RpcBlockHash> for BlockId
impl From<RpcBlockHash> for BlockId
Source§fn from(value: RpcBlockHash) -> BlockId
fn from(value: RpcBlockHash) -> BlockId
Converts to this type from the input type.
Source§impl Serialize for BlockId
Available on crate feature serde
only.
impl Serialize for BlockId
Available on crate feature
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,
Serialize this value into the given Serde serializer. Read more
impl Copy for BlockId
impl Eq for BlockId
impl StructuralPartialEq for BlockId
Auto Trait Implementations§
impl Freeze for BlockId
impl RefUnwindSafe for BlockId
impl Send for BlockId
impl Sync for BlockId
impl Unpin for BlockId
impl UnwindSafe for BlockId
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,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)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>
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