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
32
33
34
use crate::proto::etcdserverpb;

/// Response header.
pub struct ResponseHeader {
    proto: etcdserverpb::ResponseHeader,
}

impl ResponseHeader {
    /// Get the ID of the cluster which sent the response.
    pub fn cluster_id(&self) -> u64 {
        self.proto.cluster_id
    }

    /// Get the ID of the member which sent the response.
    pub fn member_id(&self) -> u64 {
        self.proto.member_id
    }

    /// Get the key-value store revision when the request was applied.
    pub fn revision(&self) -> u64 {
        self.proto.revision as u64
    }

    /// Get the raft term when the request was applied.
    pub fn raft_term(&self) -> u64 {
        self.proto.raft_term
    }
}

impl From<etcdserverpb::ResponseHeader> for ResponseHeader {
    fn from(header: etcdserverpb::ResponseHeader) -> Self {
        Self { proto: header }
    }
}