pub trait InfluxLineResponseWrapper {
// Required method
fn process_line_protocol_response<'async_trait>(
self,
) -> Pin<Box<dyn Future<Output = Result<(), ClientError>> + Send + 'async_trait>>
where Self: 'async_trait;
}
Expand description
A trait to parse a list of dataframes from Reqwest responses.
This trait is used to attach a dataframes()
function to reqwest::Response
.
use rinfluxdb_lineprotocol::r#async::InfluxLineClientWrapper;
// Bring into scope the trait implementation
use rinfluxdb_lineprotocol::r#async::InfluxLineResponseWrapper;
// Create Reqwest client
let client = reqwest::Client::new();
// Set database name
let database = "database";
// Create data
let lines = vec![
LineBuilder::new("measurement")
.insert_field("field", 42.0)
.build(),
LineBuilder::new("measurement")
.insert_field("field", 43.0)
.insert_tag("tag", "value")
.build(),
];
// Create Influx Line Protocol request
let base_url = Url::parse("https://example.com")?;
let mut builder = client
// (this is a function added by the trait above)
.line_protocol(&base_url, &database, &lines)?;
// This is a regular Reqwest builder, and can be customized as usual
if let Some((username, password)) = Some(("username", "password")) {
builder = builder.basic_auth(username, Some(password));
}
// Create a request from the builder
let request = builder.build()?;
// Execute the request through Reqwest and obtain a response
let response = client.execute(request).await?;
// Process the response.
response.process_line_protocol_response().await?;
Required Methods§
Sourcefn process_line_protocol_response<'async_trait>(
self,
) -> Pin<Box<dyn Future<Output = Result<(), ClientError>> + Send + 'async_trait>>where
Self: 'async_trait,
fn process_line_protocol_response<'async_trait>(
self,
) -> Pin<Box<dyn Future<Output = Result<(), ClientError>> + Send + 'async_trait>>where
Self: 'async_trait,
Process the response, parsing potential errors