AnyOf

Struct AnyOf 

Source
pub struct AnyOf<T>(/* private fields */);
Expand description

A collection of filter clauses combined with logical OR semantics.

AnyOf<T> represents multiple filter conditions where a match occurs if ANY of the contained filters match. This enables fluent chaining of filters with OR logic using the .or() method.

This type is typically created by calling .or() on filter types like LogFilter, BlockFilter, TransactionFilter, or TraceFilter, and can be passed directly to query methods like where_logs(), where_blocks(), etc.

§Examples

use hypersync_net_types::{LogFilter, Query};

// Create filters that match logs from USDT OR USDC contracts
let filter = LogFilter::all()
    .and_address(["0xdac17f958d2ee523a2206206994597c13d831ec7"])? // USDT
    .or(
        LogFilter::all()
            .and_address(["0xa0b86a33e6c11c8c0c5c0b5e6adee30d1a234567"])? // USDC
    );

// Use the combined filter in a query
let query = Query::new()
    .from_block(18_000_000)
    .where_logs(filter);

§Type System

The generic parameter T represents the filter type being combined. For example:

  • AnyOf<LogFilter> for combining log filters
  • AnyOf<TransactionFilter> for combining transaction filters
  • AnyOf<BlockFilter> for combining block filters
  • AnyOf<TraceFilter> for combining trace filters

Implementations§

Source§

impl<T> AnyOf<T>

Source

pub fn new(clause: T) -> Self

Create a new AnyOf containing a single filter clause.

This is typically used internally when converting from a single filter to an AnyOf. Most users will create AnyOf instances by calling .or() on filter types.

§Arguments
  • clause - The initial filter clause
§Examples
use hypersync_net_types::{LogFilter, types::AnyOf};

let filter = LogFilter::all();
let any_clause = AnyOf::new(filter);
Source

pub fn any<I>(clauses: I) -> Self
where I: IntoIterator<Item = T>,

Create an AnyOf from multiple filter clauses.

This method accepts any iterable collection of filter clauses and creates an AnyOf that matches if any of the provided clauses match. This is useful when you have a collection of filters to combine.

§Arguments
  • clauses - An iterable collection of filter clauses
§Examples
use hypersync_net_types::{LogFilter, types::AnyOf};

let filters = vec![
    LogFilter::all().and_address(["0xdac17f958d2ee523a2206206994597c13d831ec7"]).unwrap(),
    LogFilter::all().and_address(["0xa0b86a33e6c11c8c0c5c0b5e6adee30d1a234567"]).unwrap(),
];
let any_clause = AnyOf::any(filters);
Source

pub fn or(self, clause: T) -> Self

Add another filter clause to this AnyOf with OR logic.

This method extends the current AnyOf with an additional filter clause. The resulting AnyOf will match if any of the contained clauses match, including both the existing clauses and the newly added one.

This enables fluent chaining: clause1.or(clause2).or(clause3).

§Arguments
  • clause - The filter clause to add
§Returns

The updated AnyOf containing the additional clause

§Examples
use hypersync_net_types::LogFilter;

// Chain multiple filters with OR logic
let filter = LogFilter::all()
    .and_address(["0xdac17f958d2ee523a2206206994597c13d831ec7"])? // USDT
    .or(LogFilter::all().and_address(["0xa0b86a33e6c11c8c0c5c0b5e6adee30d1a234567"])?) // USDC  
    .or(LogFilter::all().and_address(["0x6b175474e89094c44da98b954eedeac495271d0f"])?); // DAI

Trait Implementations§

Source§

impl From<BlockFilter> for AnyOf<BlockFilter>

Source§

fn from(filter: BlockFilter) -> Self

Converts to this type from the input type.
Source§

impl From<LogFilter> for AnyOf<LogFilter>

Source§

fn from(filter: LogFilter) -> Self

Converts to this type from the input type.
Source§

impl<T> From<Selection<T>> for AnyOf<Selection<T>>

Source§

fn from(selection: Selection<T>) -> AnyOf<Selection<T>>

Converts to this type from the input type.
Source§

impl From<TraceFilter> for AnyOf<TraceFilter>

Source§

fn from(filter: TraceFilter) -> Self

Converts to this type from the input type.
Source§

impl From<TransactionFilter> for AnyOf<TransactionFilter>

Source§

fn from(filter: TransactionFilter) -> Self

Converts to this type from the input type.
Source§

impl<T> IntoIterator for AnyOf<T>

Source§

type Item = T

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<T>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl<T> Freeze for AnyOf<T>

§

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

§

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

§

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

§

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

§

impl<T> UnwindSafe for AnyOf<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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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.