rinfluxdb_influxql/query.rs
1// Copyright Claudio Mattera 2021.
2// Distributed under the MIT License or Apache 2.0 License at your option.
3// See accompanying files License-MIT.txt and License-Apache-2.0, or online at
4// https://opensource.org/licenses/MIT
5// https://opensource.org/licenses/Apache-2.0
6
7/// An InfluxQL query
8///
9/// A query such as
10///
11/// * `SELECT temperature, humidity FROM house..indoor_environment`
12/// * `SELECT temperature, humidity FROM house..indoor_environment WHERE time > now() - 1`
13/// * `SELECT temperature, humidity FROM house..indoor_environment GROUP BY room`
14#[derive(Debug, PartialEq)]
15pub struct Query(String);
16
17impl Query {
18 /// Create a query from a string-like object
19 pub fn new<T>(query: T) -> Self
20 where
21 T: Into<String>,
22 {
23 Self(query.into())
24 }
25}
26
27impl AsRef<str> for Query {
28 fn as_ref(&self) -> &str {
29 self.0.as_ref()
30 }
31}