pub enum BlockTransactions<T> {
Full(Vec<T>),
Hashes(Vec<B256>),
Uncle,
}
Expand description
Block Transactions depending on the boolean attribute of eth_getBlockBy*
,
or if used by eth_getUncle*
Variants§
Implementations§
Source§impl<T> BlockTransactions<T>
impl<T> BlockTransactions<T>
Sourcepub fn first_transaction(&self) -> Option<&T>
pub fn first_transaction(&self) -> Option<&T>
Returns the first transaction if the transactions are full.
Sourcepub const fn is_full(&self) -> bool
pub const fn is_full(&self) -> bool
Returns true if the enum variant is used for full transactions.
Sourcepub fn map<U>(self, f: impl FnMut(T) -> U) -> BlockTransactions<U>
pub fn map<U>(self, f: impl FnMut(T) -> U) -> BlockTransactions<U>
Converts the transaction type by applying a function to each transaction.
Returns the block with the new transaction type.
Sourcepub fn try_map<U, E>(
self,
f: impl FnMut(T) -> Result<U, E>,
) -> Result<BlockTransactions<U>, E>
pub fn try_map<U, E>( self, f: impl FnMut(T) -> Result<U, E>, ) -> Result<BlockTransactions<U>, E>
Converts the transaction type by applying a fallible function to each transaction.
Returns the block with the new transaction type if all transactions were successfully.
Sourcepub fn as_transactions(&self) -> Option<&[T]>
pub fn as_transactions(&self) -> Option<&[T]>
Fallibly cast to a slice of transactions.
Returns None
if the enum variant is not Full
.
Sourcepub fn calculate_transactions_root(&self) -> Option<B256>where
T: Encodable2718,
pub fn calculate_transactions_root(&self) -> Option<B256>where
T: Encodable2718,
Calculate the transaction root for the full transactions.
Returns None
if this is not the BlockTransactions::Full
variant
Sourcepub const fn is_uncle(&self) -> bool
pub const fn is_uncle(&self) -> bool
Returns true if the enum variant is used for an uncle response.
Sourcepub fn txns(&self) -> impl Iterator<Item = &T>
pub fn txns(&self) -> impl Iterator<Item = &T>
Returns an iterator over the transactions (if any). This will be empty if the block is an uncle or if the transaction list contains only hashes.
Sourcepub fn into_transactions(self) -> IntoIter<T>
pub fn into_transactions(self) -> IntoIter<T>
Returns an iterator over the transactions (if any). This will be empty if the block is not full.
Sourcepub fn into_transactions_vec(self) -> Vec<T>
pub fn into_transactions_vec(self) -> Vec<T>
Consumes the type and returns the transactions as a vector.
Note: if this is an uncle or hashes, this will return an empty vector.
Sourcepub fn try_into_transactions(self) -> Result<Vec<T>, ValueError<Self>>
pub fn try_into_transactions(self) -> Result<Vec<T>, ValueError<Self>>
Attempts to unwrap the Self::Full
variant.
Returns an error if the type is different variant.
Source§impl<T: TransactionResponse> BlockTransactions<T>
impl<T: TransactionResponse> BlockTransactions<T>
Sourcepub fn new_hashes(txs: impl IntoIterator<Item = impl AsRef<T>>) -> Self
pub fn new_hashes(txs: impl IntoIterator<Item = impl AsRef<T>>) -> Self
Creates a new BlockTransactions::Hashes
variant from the given iterator of transactions.
Sourcepub fn convert_to_hashes(&mut self)
pub fn convert_to_hashes(&mut self)
Converts self
into Hashes
.
Sourcepub fn convert_to_hashes_if(&mut self, condition: bool)
pub fn convert_to_hashes_if(&mut self, condition: bool)
Converts self
into Hashes
if the given condition
is true.
Sourcepub fn into_hashes(self) -> Self
pub fn into_hashes(self) -> Self
Converts self
into Hashes
.
Sourcepub fn into_hashes_if(self, condition: bool) -> Self
pub fn into_hashes_if(self, condition: bool) -> Self
Converts self
into Hashes
if the given condition
is true.
Sourcepub fn iter(&self) -> BlockTransactionHashes<'_, T> ⓘ
👎Deprecated: use hashes
instead
pub fn iter(&self) -> BlockTransactionHashes<'_, T> ⓘ
hashes
insteadReturns an iterator over the transaction hashes.
Sourcepub fn hashes(&self) -> BlockTransactionHashes<'_, T> ⓘ
pub fn hashes(&self) -> BlockTransactionHashes<'_, T> ⓘ
Returns an iterator over references to the transaction hashes.
Trait Implementations§
Source§impl<T: Clone> Clone for BlockTransactions<T>
impl<T: Clone> Clone for BlockTransactions<T>
Source§fn clone(&self) -> BlockTransactions<T>
fn clone(&self) -> BlockTransactions<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 BlockTransactions<T>
impl<T: Debug> Debug for BlockTransactions<T>
Source§impl<T> Default for BlockTransactions<T>
impl<T> Default for BlockTransactions<T>
Source§impl<'de, T> Deserialize<'de> for BlockTransactions<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for BlockTransactions<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<T> From<Vec<FixedBytes<32>>> for BlockTransactions<T>
impl<T> From<Vec<FixedBytes<32>>> for BlockTransactions<T>
Source§impl<T: TransactionResponse> From<Vec<T>> for BlockTransactions<T>
impl<T: TransactionResponse> From<Vec<T>> for BlockTransactions<T>
Source§impl<T: PartialEq> PartialEq for BlockTransactions<T>
impl<T: PartialEq> PartialEq for BlockTransactions<T>
Source§impl<T> Serialize for BlockTransactions<T>where
T: Serialize,
impl<T> Serialize for BlockTransactions<T>where
T: Serialize,
impl<T: Eq> Eq for BlockTransactions<T>
impl<T> StructuralPartialEq for BlockTransactions<T>
Auto Trait Implementations§
impl<T> Freeze for BlockTransactions<T>
impl<T> RefUnwindSafe for BlockTransactions<T>where
T: RefUnwindSafe,
impl<T> Send for BlockTransactions<T>where
T: Send,
impl<T> Sync for BlockTransactions<T>where
T: Sync,
impl<T> Unpin for BlockTransactions<T>where
T: Unpin,
impl<T> UnwindSafe for BlockTransactions<T>where
T: UnwindSafe,
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,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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>
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 moreSource§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
Source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Layout§
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: 32 bytes
Size for each variant:
Full
: 24 bytesHashes
: 24 bytesUncle
: 0 bytes