influxdb-rust icon indicating copy to clipboard operation
influxdb-rust copied to clipboard

Refactor `InfluxDbQuery` to more ergonomic handling

Open Empty2k12 opened this issue 6 years ago • 0 comments

This issue captures some discussion from #21

@pcpthm and @Drevoed suggest refactoring the query to something like this, removing the InfluxDbQuery trait and instead turning that into an Enum.

pub enum InfluxDbQuery {
    Write(InfluxDbWriteQuery),
    Read(InfluxDbReadQuery)
}

impl InfluxDbQuery {
    pub fn build(&self) -> Result<ValidQuery, InfluxDbError> {
        use InfluxDbQuery::*;
        
        match self {
            Write(write_query) => write_query.build(),
            Read(read_query) => read_query.build()
        }
    }
}

Empty2k12 avatar Oct 11 '19 20:10 Empty2k12