pub enum BlockTransactions<T> {
Full(Vec<T>),
Hashes(Vec<FixedBytes<32>>),
Uncle,
}Expand description
Block Transactions depending on the boolean attribute of eth_getBlockBy*,
or if used by eth_getUncle*
Variants§
Full(Vec<T>)
Full transactions
Hashes(Vec<FixedBytes<32>>)
Only hashes
Uncle
Special case for uncle response.
Implementations§
Source§impl<T> BlockTransactions<T>
impl<T> BlockTransactions<T>
Sourcepub fn as_hashes(&self) -> Option<&[FixedBytes<32>]>
pub fn as_hashes(&self) -> Option<&[FixedBytes<32>]>
Fallibly cast to a slice of hashes.
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<FixedBytes<32>>where
T: Encodable2718,
pub fn calculate_transactions_root(&self) -> Option<FixedBytes<32>>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<BlockTransactions<T>>>
pub fn try_into_transactions( self, ) -> Result<Vec<T>, ValueError<BlockTransactions<T>>>
Attempts to unwrap the Self::Full variant.
Returns an error if the type is different variant.
Sourcepub const fn uncle() -> BlockTransactions<T>
pub const fn uncle() -> BlockTransactions<T>
Returns an instance of BlockTransactions with the Uncle special case.
Source§impl<T> BlockTransactions<T>where
T: TransactionResponse,
impl<T> BlockTransactions<T>where
T: TransactionResponse,
Sourcepub fn new_hashes(
txs: impl IntoIterator<Item = impl AsRef<T>>,
) -> BlockTransactions<T>
pub fn new_hashes( txs: impl IntoIterator<Item = impl AsRef<T>>, ) -> BlockTransactions<T>
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) -> BlockTransactions<T>
pub fn into_hashes(self) -> BlockTransactions<T>
Converts self into Hashes.
Sourcepub fn into_hashes_if(self, condition: bool) -> BlockTransactions<T>
pub fn into_hashes_if(self, condition: bool) -> BlockTransactions<T>
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 for BlockTransactions<T>where
T: Clone,
impl<T> Clone for BlockTransactions<T>where
T: Clone,
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 for BlockTransactions<T>where
T: Debug,
impl<T> Debug for BlockTransactions<T>where
T: Debug,
Source§impl<T> Default for BlockTransactions<T>
impl<T> Default for BlockTransactions<T>
Source§fn default() -> BlockTransactions<T>
fn default() -> 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<BlockTransactions<T>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<BlockTransactions<T>, <__D as Deserializer<'de>>::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§fn from(hashes: Vec<FixedBytes<32>>) -> BlockTransactions<T>
fn from(hashes: Vec<FixedBytes<32>>) -> BlockTransactions<T>
Source§impl<T> From<Vec<T>> for BlockTransactions<T>where
T: TransactionResponse,
impl<T> From<Vec<T>> for BlockTransactions<T>where
T: TransactionResponse,
Source§fn from(transactions: Vec<T>) -> BlockTransactions<T>
fn from(transactions: Vec<T>) -> BlockTransactions<T>
Source§impl<T> PartialEq for BlockTransactions<T>where
T: PartialEq,
impl<T> PartialEq for BlockTransactions<T>where
T: PartialEq,
Source§impl<T> Serialize for BlockTransactions<T>where
T: Serialize,
impl<T> Serialize for BlockTransactions<T>where
T: Serialize,
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<T> Eq for BlockTransactions<T>where
T: Eq,
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> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.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> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.