Struct Log

Source
pub struct Log<T = LogData> {
    pub inner: Log<T>,
    pub block_hash: Option<BlockHash>,
    pub block_number: Option<u64>,
    pub block_timestamp: Option<u64>,
    pub transaction_hash: Option<TxHash>,
    pub transaction_index: Option<u64>,
    pub log_index: Option<u64>,
    pub removed: bool,
}
Expand description

Ethereum Log emitted by a transaction

Fields§

§inner: Log<T>

Consensus log object

§block_hash: Option<BlockHash>

Hash of the block the transaction that emitted this log was mined in

§block_number: Option<u64>

Number of the block the transaction that emitted this log was mined in

§block_timestamp: Option<u64>§transaction_hash: Option<TxHash>

Transaction Hash

§transaction_index: Option<u64>

Index of the Transaction in the block

§log_index: Option<u64>

Log Index in Block

§removed: bool

Geth Compatibility Field: whether this log was removed

Implementations§

Source§

impl<T> Log<T>

Source

pub const fn address(&self) -> Address

Getter for the address field. Shortcut for log.inner.address.

Source

pub const fn data(&self) -> &T

Getter for the data field. Shortcut for log.inner.data.

Source

pub fn into_inner(self) -> Log<T>

Consumes the type and returns the wrapped alloy_primitives::Log

Source§

impl Log<LogData>

Source

pub fn topics(&self) -> &[B256]

Getter for the topics field. Shortcut for log.inner.topics().

Source

pub fn topic0(&self) -> Option<&B256>

Getter for the topic0 field.

Source

pub fn topics_mut(&mut self) -> &mut [B256]

Get the topic list, mutably. This gives access to the internal array, without allowing extension of that array. Shortcut for LogData::topics_mut

Source

pub fn log_decode<T: SolEvent>(&self) -> Result<Log<T>>

Decode the log data into a typed log.

Source

pub fn log_decode_validate<T: SolEvent>(&self) -> Result<Log<T>>

Decode the log data with validation into a typed log.

Source

pub fn collect_for_receipt<I, T>( previous_log_count: usize, meta: TransactionMeta, logs: I, ) -> Vec<Log<T>>
where I: IntoIterator<Item = Log<T>>,

Creates a collection of RPC logs from transaction receipt logs.

This function takes raw consensus logs and enriches them with RPC metadata needed for API responses, including block information and proper indexing.

§Arguments
  • previous_log_count - The total number of logs from previous transactions in the same block. Used to calculate the correct log_index for each log.
  • meta - Transaction metadata containing block hash, number, timestamp, and transaction information needed to populate the RPC log fields.
  • logs - An iterator of consensus logs to be converted into RPC logs.
§Returns

A vector of RPC logs with all metadata fields populated, ready to be included in the transaction receipt.

Source§

impl<T> Log<T>
where for<'a> &'a T: Into<LogData>,

Source

pub fn reserialize_inner(&self) -> Log

Reserialize the inner data, returning an alloy_primitives::Log.

Source

pub fn reserialize(&self) -> Log<LogData>

Reserialize the data, returning a new Log object wrapping an alloy_primitives::Log. this copies the log metadata, preserving the original object.

Trait Implementations§

Source§

impl<T> AsMut<Log<T>> for Log<T>

Source§

fn as_mut(&mut self) -> &mut Log<T>

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<T> AsMut<T> for Log<T>

Source§

fn as_mut(&mut self) -> &mut T

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<T> AsRef<Log<T>> for Log<T>

Source§

fn as_ref(&self) -> &Log<T>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<T> AsRef<T> for Log<T>

Source§

fn as_ref(&self) -> &T

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<T: Clone> Clone for Log<T>

Source§

fn clone(&self) -> Log<T>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for Log<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Default> Default for Log<T>

Source§

fn default() -> Log<T>

Returns the “default value” for a type. Read more
Source§

impl<'de, T> Deserialize<'de> for Log<T>
where T: Deserialize<'de>,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T> Encodable for Log<T>
where for<'a> &'a T: Into<LogData>,

Source§

fn encode(&self, out: &mut dyn BufMut)

Encodes the type into the out buffer.
Source§

fn length(&self) -> usize

Returns the length of the encoding of this type in bytes. Read more
Source§

impl<L> From<Log<L>> for Log<L>

Source§

fn from(value: Log<L>) -> Self

Converts to this type from the input type.
Source§

impl<T: Hash> Hash for Log<T>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T: PartialEq> PartialEq for Log<T>

Source§

fn eq(&self, other: &Log<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T> Serialize for Log<T>
where T: Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<T: Eq> Eq for Log<T>

Source§

impl<T> StructuralPartialEq for Log<T>

Auto Trait Implementations§

§

impl<T> Freeze for Log<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Log<T>
where T: RefUnwindSafe,

§

impl<T> Send for Log<T>
where T: Send,

§

impl<T> Sync for Log<T>
where T: Sync,

§

impl<T> Unpin for Log<T>
where T: Unpin,

§

impl<T> UnwindSafe for Log<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,