pub struct Query { /* private fields */ }
Expand description

A structured query for use in interacting with the Tendermint RPC event subscription system.

Allows for compile-time validation of queries.

See the subscribe endpoint documentation for more details.

Examples

Direct construction of queries

use tendermint_rpc::query::{Query, EventType};

let query = Query::from(EventType::NewBlock);
assert_eq!("tm.event = 'NewBlock'", query.to_string());

let query = Query::from(EventType::Tx).and_eq("tx.hash", "XYZ");
assert_eq!("tm.event = 'Tx' AND tx.hash = 'XYZ'", query.to_string());

let query = Query::from(EventType::Tx).and_gte("tx.height", 100_u64);
assert_eq!("tm.event = 'Tx' AND tx.height >= 100", query.to_string());

Query parsing

use tendermint_rpc::query::{Query, EventType};

let query: Query = "tm.event = 'NewBlock'".parse().unwrap();
assert_eq!(query, Query::from(EventType::NewBlock));

let query: Query = "tm.event = 'Tx' AND tx.hash = 'XYZ'".parse().unwrap();
assert_eq!(query, Query::from(EventType::Tx).and_eq("tx.hash", "XYZ"));

let query: Query = "tm.event = 'Tx' AND tx.height >= 100".parse().unwrap();
assert_eq!(query, Query::from(EventType::Tx).and_gte("tx.height", 100_u64));

Implementations

Query constructor testing whether <key> = <value>

Query constructor testing whether <key> < <value>

Query constructor testing whether <key> <= <value>

Query constructor testing whether <key> > <value>

Query constructor testing whether <key> >= <value>

Query constructor testing whether <key> CONTAINS <value> (assuming key contains a string, this tests whether value is a sub-string within it).

Query constructor testing whether <key> EXISTS.

Add the condition <key> = <value> to the query.

Add the condition <key> < <value> to the query.

Add the condition <key> <= <value> to the query.

Add the condition <key> > <value> to the query.

Add the condition <key> >= <value> to the query.

Add the condition <key> CONTAINS <value> to the query.

Add the condition <key> EXISTS 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

An empty query matches any set of events. See these docs.

Formats the value using the given formatter. Read more

Converts to this type from the input type.

The associated error which can be returned from parsing.

Parses a string s to return a value of this type. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

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.

Should always be Self

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

Converts the given value to a String. 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.

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