etcd_rs/lease/
keep_alive.rs

1use crate::lease::LeaseId;
2use crate::proto::etcdserverpb;
3use crate::ResponseHeader;
4
5#[derive(Debug)]
6pub struct LeaseKeepAliveRequest {
7    proto: crate::proto::etcdserverpb::LeaseKeepAliveRequest,
8}
9
10impl LeaseKeepAliveRequest {
11    /// Creates a new LeaseKeepAliveRequest which will refresh the specified lease.
12    pub fn new(id: LeaseId) -> Self {
13        Self {
14            proto: etcdserverpb::LeaseKeepAliveRequest { id },
15        }
16    }
17}
18
19impl From<LeaseKeepAliveRequest> for crate::proto::etcdserverpb::LeaseKeepAliveRequest {
20    fn from(x: LeaseKeepAliveRequest) -> Self {
21        x.proto
22    }
23}
24
25#[derive(Debug)]
26pub struct LeaseKeepAliveResponse {
27    pub header: ResponseHeader,
28    pub id: LeaseId,
29    pub ttl: i64,
30}
31
32impl From<crate::proto::etcdserverpb::LeaseKeepAliveResponse> for LeaseKeepAliveResponse {
33    fn from(proto: crate::proto::etcdserverpb::LeaseKeepAliveResponse) -> Self {
34        Self {
35            header: From::from(proto.header.expect("must fetch header")),
36            id: proto.id,
37            ttl: proto.ttl,
38        }
39    }
40}