Trait influx_db_client::InfluxClient [] [src]

pub trait InfluxClient {
    fn ping(&self) -> bool;
    fn get_version(&self) -> Option<String>;
    fn write_point(
        &self,
        point: Point,
        precision: Option<Precision>,
        rp: Option<&str>
    ) -> Result<bool, Error>; fn write_points(
        &self,
        points: Points,
        precision: Option<Precision>,
        rp: Option<&str>
    ) -> Result<bool, Error>; fn query(
        &self,
        q: &str,
        epoch: Option<Precision>
    ) -> Result<Vec<Value>, Error>; fn drop_measurement(&self, measurement: &str) -> Result<(), Error>; fn create_database(&self, dbname: &str) -> Result<(), Error>; fn drop_database(&self, dbname: &str) -> Result<(), Error>; fn create_user(
        &self,
        user: &str,
        passwd: &str,
        admin: bool
    ) -> Result<(), Error>; fn drop_user(&self, user: &str) -> Result<(), Error>; fn set_user_password(&self, user: &str, passwd: &str) -> Result<(), Error>; fn grant_admin_privileges(&self, user: &str) -> Result<(), Error>; fn revoke_admin_privileges(&self, user: &str) -> Result<(), Error>; fn grant_privilege(
        &self,
        user: &str,
        db: &str,
        privilege: &str
    ) -> Result<(), Error>; fn revoke_privilege(
        &self,
        user: &str,
        db: &str,
        privilege: &str
    ) -> Result<(), Error>; fn create_retention_policy(
        &self,
        name: &str,
        duration: &str,
        replication: &str,
        default: bool,
        db: Option<&str>
    ) -> Result<(), Error>; fn drop_retention_policy(
        &self,
        name: &str,
        db: Option<&str>
    ) -> Result<(), Error>; }

Required Methods

Query whether the corresponding database exists, return bool

Query the version of the database and return the version number

Write a point to the database

Write multiple points to the database

let mut client = InfluxdbClient::new("http://localhost:8086", "test", "root", "root");
client.set_write_timeout(10);
client.set_read_timeout(10);

let mut point = Point::new("test");
point.add_field("somefield", Value::Integer(65));

let mut point1 = Point::new("test2");
point1.add_field("somefield", Value::Float(12.2));
point1.add_tag("sometag", Value::Boolean(false));

let mut points = Points::new(point);
points.push(point1);

if Precision is None, the default is second
Multiple write
let res = client.write_points(points, Some(Precision::Microseconds), None).unwrap();

Query and return data, the data type is Vec<serde_json::Value>, such as "show, select"

let client = InfluxdbClient::new("http://localhost:8086", "test", "root", "root");
let res = client.query("select * from test", None).unwrap();
println!("{:?}", res[0].get("series").unwrap()[0].get("values"));

Create a new database in InfluxDB.

Drop a database from InfluxDB.

Create a new user in InfluxDB.

Drop a user from InfluxDB.

Change the password of an existing user.

Grant cluster administration privileges to a user.

Revoke cluster administration privileges from a user.

Grant a privilege on a database to a user. :param privilege: the privilege to grant, one of 'read', 'write' or 'all'. The string is case-insensitive

Revoke a privilege on a database from a user. :param privilege: the privilege to grant, one of 'read', 'write' or 'all'. The string is case-insensitive

Create a retention policy for a database.

Drop an existing retention policy for a database.

Implementors