pub struct ChainQueryFilter {
    pub sequence_range: ChainQueryFilterRange,
    pub entry_type: Option<EntryType>,
    pub entry_hashes: Option<HashSet<EntryHash>>,
    pub action_type: Option<ActionType>,
    pub include_entries: bool,
    pub order_descending: bool,
}
Expand description

Specifies arguments to a query of the source chain, including ordering and filtering.

This struct is used to construct an actual SQL query on the database, and also has methods to allow filtering in-memory.

Fields§

§sequence_range: ChainQueryFilterRange

Limit the results to a range of records according to their actions.

§entry_type: Option<EntryType>

Filter by EntryType

§entry_hashes: Option<HashSet<EntryHash>>

Filter by a list of EntryHash.

§action_type: Option<ActionType>

Filter by ActionType

§include_entries: bool

Include the entries in the records

§order_descending: bool

The query should be ordered in descending order (default is ascending), when run as a database query. There is no provisioning for in-memory ordering.

Implementations§

Create a no-op ChainQueryFilter which returns everything.

Filter on sequence range.

Filter on entry type.

Filter on entry hashes.

Filter on action type.

Include the entries in the RecordsVec that is returned.

Set the order to ascending.

Set the order to ascending.

If the sequence range supports fork disambiguation, apply it to remove actions that are not in the correct branch. Numerical range bounds do NOT support fork disambiguation, and neither does unbounded, but everything hash bounded does.

Examples found in repository?
src/query.rs (line 287)
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
    pub fn filter_actions(&self, actions: Vec<ActionHashed>) -> Vec<ActionHashed> {
        self.disambiguate_forks(actions)
            .into_iter()
            .filter(|action| {
                self.action_type
                    .as_ref()
                    .map(|action_type| action.action_type() == *action_type)
                    .unwrap_or(true)
                    && self
                        .entry_type
                        .as_ref()
                        .map(|entry_type| action.entry_type() == Some(entry_type))
                        .unwrap_or(true)
                    && self
                        .entry_hashes
                        .as_ref()
                        .map(|entry_hashes| match action.entry_hash() {
                            Some(entry_hash) => entry_hashes.contains(entry_hash),
                            None => false,
                        })
                        .unwrap_or(true)
            })
            .collect()
    }

Filter a vector of hashed actions according to the query.

Examples found in repository?
src/query.rs (lines 313-318)
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
    pub fn filter_records(&self, records: Vec<Record>) -> Vec<Record> {
        let actions = self.filter_actions(
            records
                .iter()
                .map(|record| record.action_hashed().clone())
                .collect(),
        );
        let action_hashset = actions
            .iter()
            .map(|action| action.as_hash().clone())
            .collect::<HashSet<ActionHash>>();
        records
            .into_iter()
            .filter(|record| action_hashset.contains(record.action_address()))
            .collect()
    }

Filter a vector of records according to the query.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Deserialize this value from the given Serde deserializer. Read more
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Serialize this value into the given Serde serializer. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
The archived version of the pointer metadata for this type.
Converts some archived metadata to the pointer metadata for itself.
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Deserializes using the given deserializer

Returns the argument unchanged.

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

Calls U::from(self).

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

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
The type for metadata in pointers and references to Self.
Should always be Self
The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Checks if self is actually part of its subset T (and can be converted to it).
Use with care! Same as self.to_subset but without any property checks. Always succeeds.
The inclusion map: converts self to the equivalent element of its superset.
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
upcast ref
upcast mut ref
upcast boxed dyn
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more