1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
mod authenticate;
pub use authenticate::{AuthenticateRequest, AuthenticateResponse};
use tonic::transport::Channel;
use crate::proto::etcdserverpb::auth_client::AuthClient;
use crate::Result as Res;
#[derive(Clone)]
pub struct Auth {
client: AuthClient<Channel>,
}
impl Auth {
pub(crate) fn new(client: AuthClient<Channel>) -> Self {
Self { client }
}
pub async fn authenticate(&mut self, req: AuthenticateRequest) -> Res<AuthenticateResponse> {
let resp = self
.client
.authenticate(tonic::Request::new(req.into()))
.await?;
Ok(From::from(resp.into_inner()))
}
}