forked from zarvd/etcd-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
keep_alive.rs
40 lines (35 loc) · 1.05 KB
/
keep_alive.rs
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
35
36
37
38
39
40
use crate::lease::LeaseId;
use crate::proto::etcdserverpb;
use crate::ResponseHeader;
#[derive(Debug)]
pub struct LeaseKeepAliveRequest {
proto: crate::proto::etcdserverpb::LeaseKeepAliveRequest,
}
impl LeaseKeepAliveRequest {
/// Creates a new LeaseKeepAliveRequest which will refresh the specified lease.
pub fn new(id: LeaseId) -> Self {
Self {
proto: etcdserverpb::LeaseKeepAliveRequest { id },
}
}
}
impl From<LeaseKeepAliveRequest> for crate::proto::etcdserverpb::LeaseKeepAliveRequest {
fn from(x: LeaseKeepAliveRequest) -> Self {
x.proto
}
}
#[derive(Debug)]
pub struct LeaseKeepAliveResponse {
pub header: ResponseHeader,
pub id: LeaseId,
pub ttl: i64,
}
impl From<crate::proto::etcdserverpb::LeaseKeepAliveResponse> for LeaseKeepAliveResponse {
fn from(proto: crate::proto::etcdserverpb::LeaseKeepAliveResponse) -> Self {
Self {
header: From::from(proto.header.expect("must fetch header")),
id: proto.id,
ttl: proto.ttl,
}
}
}