Struct tendermint_rpc::query::Query
source · [−]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
sourceimpl Query
impl Query
sourcepub fn eq(key: impl ToString, value: impl Into<Operand>) -> Self
pub fn eq(key: impl ToString, value: impl Into<Operand>) -> Self
Query constructor testing whether <key> = <value>
sourcepub fn lt(key: impl ToString, value: impl Into<Operand>) -> Self
pub fn lt(key: impl ToString, value: impl Into<Operand>) -> Self
Query constructor testing whether <key> < <value>
sourcepub fn lte(key: impl ToString, value: impl Into<Operand>) -> Self
pub fn lte(key: impl ToString, value: impl Into<Operand>) -> Self
Query constructor testing whether <key> <= <value>
sourcepub fn gt(key: impl ToString, value: impl Into<Operand>) -> Self
pub fn gt(key: impl ToString, value: impl Into<Operand>) -> Self
Query constructor testing whether <key> > <value>
sourcepub fn gte(key: impl ToString, value: impl Into<Operand>) -> Self
pub fn gte(key: impl ToString, value: impl Into<Operand>) -> Self
Query constructor testing whether <key> >= <value>
sourcepub fn contains(key: impl ToString, value: impl ToString) -> Self
pub fn contains(key: impl ToString, value: impl ToString) -> Self
Query constructor testing whether <key> CONTAINS <value> (assuming
key contains a string, this tests whether value is a sub-string
within it).
sourcepub fn and_eq(self, key: impl ToString, value: impl Into<Operand>) -> Self
pub fn and_eq(self, key: impl ToString, value: impl Into<Operand>) -> Self
Add the condition <key> = <value> to the query.
sourcepub fn and_lt(self, key: impl ToString, value: impl Into<Operand>) -> Self
pub fn and_lt(self, key: impl ToString, value: impl Into<Operand>) -> Self
Add the condition <key> < <value> to the query.
sourcepub fn and_lte(self, key: impl ToString, value: impl Into<Operand>) -> Self
pub fn and_lte(self, key: impl ToString, value: impl Into<Operand>) -> Self
Add the condition <key> <= <value> to the query.
sourcepub fn and_gt(self, key: impl ToString, value: impl Into<Operand>) -> Self
pub fn and_gt(self, key: impl ToString, value: impl Into<Operand>) -> Self
Add the condition <key> > <value> to the query.
sourcepub fn and_gte(self, key: impl ToString, value: impl Into<Operand>) -> Self
pub fn and_gte(self, key: impl ToString, value: impl Into<Operand>) -> Self
Add the condition <key> >= <value> to the query.
sourcepub fn and_contains(self, key: impl ToString, value: impl ToString) -> Self
pub fn and_contains(self, key: impl ToString, value: impl ToString) -> Self
Add the condition <key> CONTAINS <value> to the query.
sourcepub fn and_exists(self, key: impl ToString) -> Self
pub fn and_exists(self, key: impl ToString) -> Self
Add the condition <key> EXISTS to the query.
Trait Implementations
sourceimpl Default for Query
impl Default for Query
sourcefn default() -> Self
fn default() -> Self
An empty query matches any set of events. See these docs.
impl StructuralPartialEq for Query
Auto Trait Implementations
impl RefUnwindSafe for Query
impl Send for Query
impl Sync for Query
impl Unpin for Query
impl UnwindSafe for Query
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more