pub struct Selection<T> {
pub include: T,
pub exclude: Option<T>,
}Fields§
§include: TFilters where matching values should be included in the response Default::default() means include everything
exclude: Option<T>Filters where matching values should be excluded from the response None means exclude nothing, Some(Default::default()) means exclude everything
Implementations§
Source§impl<T> Selection<T>
impl<T> Selection<T>
Sourcepub fn new(filter: T) -> Self
pub fn new(filter: T) -> Self
Create a new selection with the given filter.
§Arguments
filter- The filter to include in the selection
§Examples
use hypersync_net_types::{LogSelection, LogFilter};
// Create a selection that includes the filter
let selection = LogSelection::new(
LogFilter::all().and_address(["0xdadB0d80178819F2319190D340ce9A924f783711"])?,
);
Ok::<(), anyhow::Error>(())Sourcepub fn and_not(self, filter: T) -> Self
pub fn and_not(self, filter: T) -> Self
Add a filter to exclude from the selection
§Arguments
filter- The filter to exclude from the selection
§Examples
use hypersync_net_types::{LogSelection, LogFilter};
// Create a selection with a filter that matches any log. (or your own filter)
let all = LogSelection::new(LogFilter::all());
// Create a selection that excludes only logs from a specific address
let selection = all.and_not(
LogFilter::all().and_address(["0xa0b86a33e6c11c8c0c5c0b5e6adee30d1a234567"])?,
);
Ok::<(), anyhow::Error>(())Sourcepub fn or(self, selection: Self) -> AnyOf<Self>
pub fn or(self, selection: Self) -> AnyOf<Self>
Combine this selection with another selection using logical OR.
This creates an AnyOf type that will match if either this selection
or the provided selection matches.
§Arguments
selection- Another selection to combine with this one
§Returns
An AnyOf<Self> that represents the logical OR of both selections
§Examples
use hypersync_net_types::{LogSelection, LogFilter};
// Create two different selections
let selection1 = LogSelection::new(LogFilter::all())
.and_not(LogFilter::all().and_address(["0xdadB0d80178819F2319190D340ce9A924f783711"])?);
let selection2 = LogSelection::new(
LogFilter::all().and_address(["0xa0b86a33e6c11c8c0c5c0b5e6adee30d1a234567"])?,
);
// Combine them with OR - matches logs from either address
let combined = selection1.or(selection2);
Ok::<(), anyhow::Error>(())Trait Implementations§
Source§impl<O, T> CapnpBuilder<Owned<O>> for Selection<T>where
O: Owned,
T: CapnpBuilder<O>,
impl<O, T> CapnpBuilder<Owned<O>> for Selection<T>where
O: Owned,
T: CapnpBuilder<O>,
Source§impl<O, T> CapnpReader<Owned<O>> for Selection<T>where
O: Owned,
T: CapnpReader<O>,
impl<O, T> CapnpReader<Owned<O>> for Selection<T>where
O: Owned,
T: CapnpReader<O>,
Source§impl<'de, T> Deserialize<'de> for Selection<T>where
T: Deserialize<'de> + Default,
impl<'de, T> Deserialize<'de> for Selection<T>where
T: Deserialize<'de> + Default,
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>,
Deserialize this value from the given Serde deserializer. Read more
impl<T> StructuralPartialEq for Selection<T>
Auto Trait Implementations§
impl<T> Freeze for Selection<T>where
T: Freeze,
impl<T> RefUnwindSafe for Selection<T>where
T: RefUnwindSafe,
impl<T> Send for Selection<T>where
T: Send,
impl<T> Sync for Selection<T>where
T: Sync,
impl<T> Unpin for Selection<T>where
T: Unpin,
impl<T> UnwindSafe for Selection<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
Mutably borrows from an owned value. Read more