ya_etcd_rs/auth/
role_add.rs

1use crate::ResponseHeader;
2use crate::proto::etcdserverpb;
3
4#[derive(Debug, Clone)]
5pub struct AuthRoleAddRequest {
6    proto: etcdserverpb::AuthRoleAddRequest,
7}
8
9impl AuthRoleAddRequest {
10    pub fn new(name: impl Into<String>) -> Self {
11        Self {
12            proto: etcdserverpb::AuthRoleAddRequest { name: name.into() },
13        }
14    }
15}
16
17impl<I> From<I> for AuthRoleAddRequest
18where
19    I: Into<String>,
20{
21    fn from(name: I) -> Self {
22        Self::new(name)
23    }
24}
25
26impl From<AuthRoleAddRequest> for etcdserverpb::AuthRoleAddRequest {
27    fn from(req: AuthRoleAddRequest) -> Self {
28        req.proto
29    }
30}
31
32#[derive(Debug, Clone)]
33pub struct AuthRoleAddResponse {
34    pub header: ResponseHeader,
35}
36
37impl From<etcdserverpb::AuthRoleAddResponse> for AuthRoleAddResponse {
38    fn from(proto: etcdserverpb::AuthRoleAddResponse) -> Self {
39        Self {
40            header: From::from(proto.header.expect("must fetch header")),
41        }
42    }
43}