pub struct Client { /* private fields */ }
Expand description
Internal Representation of a Client
Implementations
sourceimpl Client
impl Client
sourcepub fn with_auth<S1, S2>(self, username: S1, password: S2) -> Self where
S1: Into<String>,
S2: Into<String>,
pub fn with_auth<S1, S2>(self, username: S1, password: S2) -> Self where
S1: Into<String>,
S2: Into<String>,
sourcepub fn with_http_client(self, http_client: HttpClient) -> Self
pub fn with_http_client(self, http_client: HttpClient) -> Self
Replaces the HTTP Client
sourcepub fn database_name(&self) -> &str
pub fn database_name(&self) -> &str
Returns the name of the database the client is using
sourcepub fn database_url(&self) -> &str
pub fn database_url(&self) -> &str
Returns the URL of the InfluxDB installation the client is using
sourcepub async fn ping(&self) -> Result<(String, String), Error>
pub async fn ping(&self) -> Result<(String, String), Error>
Pings the InfluxDB Server
Returns a tuple of build type and version number
sourcepub async fn query<Q>(&self, q: Q) -> Result<String, Error> where
Q: Query,
pub async fn query<Q>(&self, q: Q) -> Result<String, Error> where
Q: Query,
Sends a ReadQuery
or WriteQuery
to the InfluxDB Server.
A version capable of parsing the returned string is available under the serde_integration
Arguments
q
: Query of typeReadQuery
orWriteQuery
Examples
use influxdb::{Client, Query, Timestamp};
use influxdb::InfluxDbWriteable;
use std::time::{SystemTime, UNIX_EPOCH};
let start = SystemTime::now();
let since_the_epoch = start
.duration_since(UNIX_EPOCH)
.expect("Time went backwards")
.as_millis();
let client = Client::new("http://localhost:8086", "test");
let query = Timestamp::Milliseconds(since_the_epoch)
.into_query("weather")
.add_field("temperature", 82);
let results = client.query(query).await?;
Errors
If the function can not finish the query,
a Error
variant will be returned.
sourceimpl Client
impl Client
pub async fn json_query(
&self,
q: ReadQuery
) -> Result<DatabaseQueryResult, Error>
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more