pub enum Credentials {
Basic {
user: String,
passwd: String,
cookie: Option<String>,
},
Token {
token: String,
},
}
Expand description
Credentials used to authenticate at the InfluxDB server
Variants§
Basic
HTTP Basic authentication pattern. This pattern authenticates at the server and receives back the token to use for subsequent queries against the API.
Fields
Internally keeps track of the token provided by DB after basic auth.
Token
Provide token generated directly in the InfluxDB GUI or CLI.
Implementations§
Source§impl Credentials
impl Credentials
Sourcepub fn from_basic(user: &str, passwd: &str) -> Self
pub fn from_basic(user: &str, passwd: &str) -> Self
User and password for HTTP basic auth at the server API
Examples found in repository?
examples/simple.rs (line 18)
16fn main() -> Result<(), InfluxError>
17{
18 let creds = Credentials::from_basic("testuser", "testpasswd");
19 let backlog = FileBacklog::new("./ignore/backlog")?;
20
21 let mut client = Client::build("http://127.0.0.1:8086".into(), creds)
22 .backlog(backlog)
23 .finish()?;
24
25 let mut rec = Record::new("org", "bucket")
26 .precision(Precision::Milliseconds);
27
28 loop
29 {
30 rec.measurement("sensor1")
31 .tag("floor", "second")
32 .tag("exposure", "west")
33 .field("temp", 123)
34 .field("brightness", 500);
35
36 rec.measurement("sensor2")
37 .tag("floor", "second")
38 .tag("exposure", "east")
39 .field("temp", 321)
40 .field("brightness", 999);
41
42 if let Err(e) = client.write(&rec) {
43 eprintln!("{}", e);
44 }
45
46 sleep(Duration::from_secs(1));
47 }
48}
Sourcepub fn from_token(token: &str) -> Self
pub fn from_token(token: &str) -> Self
Token to utilize for requests at the server API
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Credentials
impl RefUnwindSafe for Credentials
impl Send for Credentials
impl Sync for Credentials
impl Unpin for Credentials
impl UnwindSafe for Credentials
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more