pub struct Query {
pub event_type: Option<EventType>,
pub conditions: Vec<Condition>,
}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));Fields§
§event_type: Option<EventType>§conditions: Vec<Condition>Implementations§
Source§impl Query
impl Query
Sourcepub fn eq(key: impl ToString, value: impl Into<Operand>) -> Query
pub fn eq(key: impl ToString, value: impl Into<Operand>) -> Query
Query constructor testing whether <key> = <value>
Sourcepub fn lt(key: impl ToString, value: impl Into<Operand>) -> Query
pub fn lt(key: impl ToString, value: impl Into<Operand>) -> Query
Query constructor testing whether <key> < <value>
Sourcepub fn lte(key: impl ToString, value: impl Into<Operand>) -> Query
pub fn lte(key: impl ToString, value: impl Into<Operand>) -> Query
Query constructor testing whether <key> <= <value>
Sourcepub fn gt(key: impl ToString, value: impl Into<Operand>) -> Query
pub fn gt(key: impl ToString, value: impl Into<Operand>) -> Query
Query constructor testing whether <key> > <value>
Sourcepub fn gte(key: impl ToString, value: impl Into<Operand>) -> Query
pub fn gte(key: impl ToString, value: impl Into<Operand>) -> Query
Query constructor testing whether <key> >= <value>
Sourcepub fn contains(key: impl ToString, value: impl ToString) -> Query
pub fn contains(key: impl ToString, value: impl ToString) -> Query
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>) -> Query
pub fn and_eq(self, key: impl ToString, value: impl Into<Operand>) -> Query
Add the condition <key> = <value> to the query.
Sourcepub fn and_lt(self, key: impl ToString, value: impl Into<Operand>) -> Query
pub fn and_lt(self, key: impl ToString, value: impl Into<Operand>) -> Query
Add the condition <key> < <value> to the query.
Sourcepub fn and_lte(self, key: impl ToString, value: impl Into<Operand>) -> Query
pub fn and_lte(self, key: impl ToString, value: impl Into<Operand>) -> Query
Add the condition <key> <= <value> to the query.
Sourcepub fn and_gt(self, key: impl ToString, value: impl Into<Operand>) -> Query
pub fn and_gt(self, key: impl ToString, value: impl Into<Operand>) -> Query
Add the condition <key> > <value> to the query.
Sourcepub fn and_gte(self, key: impl ToString, value: impl Into<Operand>) -> Query
pub fn and_gte(self, key: impl ToString, value: impl Into<Operand>) -> Query
Add the condition <key> >= <value> to the query.
Sourcepub fn and_contains(self, key: impl ToString, value: impl ToString) -> Query
pub fn and_contains(self, key: impl ToString, value: impl ToString) -> Query
Add the condition <key> CONTAINS <value> to the query.
Sourcepub fn and_exists(self, key: impl ToString) -> Query
pub fn and_exists(self, key: impl ToString) -> Query
Add the condition <key> EXISTS to the query.
Trait Implementations§
Source§impl Default for Query
impl Default for Query
Source§fn default() -> Query
fn default() -> Query
An empty query matches any set of events. See these docs.
impl StructuralPartialEq for Query
Auto Trait Implementations§
impl Freeze for Query
impl RefUnwindSafe for Query
impl Send for Query
impl Sync for Query
impl Unpin for Query
impl UnsafeUnpin for Query
impl UnwindSafe for Query
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Declassify for T
impl<T> Declassify for T
type Declassified = T
fn declassify(self) -> T
Source§impl<T> Deprecatable for T
impl<T> Deprecatable for T
fn deprecate(self) -> Deprecated<Self>where
Self: Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> OptionalSet for T
impl<T> OptionalSet for T
Source§fn with_optional<F, T>(self, f: F, val: Option<T>) -> Self
fn with_optional<F, T>(self, f: F, val: Option<T>) -> Self
Some), the provided closure is applied.
Otherwise self is returned with no modifications.Source§fn with_validated_optional<F, T, V, E>(
self,
f: F,
value: Option<T>,
validate: V,
) -> Result<Self, E>
fn with_validated_optional<F, T, V, E>( self, f: F, value: Option<T>, validate: V, ) -> Result<Self, E>
Some) it is validated and then the provided closure is applied.
Otherwise self is returned with no modifications.Source§fn with_optional_env<F, T>(self, f: F, val: Option<T>, env_var: &str) -> Self
fn with_optional_env<F, T>(self, f: F, val: Option<T>, env_var: &str) -> Self
Some), the provided closure is applied.
Otherwise, if the environment was configured and the corresponding variable was set,
the value is parsed using the FromStr implementation and the closure is applied on that instead.
Finally, if none of those were available, self is returned with no modifications.Source§fn with_optional_custom_env<F, T, G>(
self,
f: F,
val: Option<T>,
env_var: &str,
parser: G,
) -> Self
fn with_optional_custom_env<F, T, G>( self, f: F, val: Option<T>, env_var: &str, parser: G, ) -> Self
Some), the provided closure is applied.
Otherwise, if the environment was configured and the corresponding variable was set,
the value is parsed using the provided parser and the closure is applied on that instead.
Finally, if none of those were available, self is returned with no modifications.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.