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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
use super::generated_ops::delete_client::{Operation as OperationProto, Result as ResultProto};
use crate::operations::delete_client::{Operation, Result};
impl From<OperationProto> for Operation {
fn from(proto_op: OperationProto) -> Self {
Operation {
client: proto_op.client,
}
}
}
impl From<Operation> for OperationProto {
fn from(op: Operation) -> Self {
OperationProto { client: op.client }
}
}
impl From<ResultProto> for Result {
fn from(_proto_op: ResultProto) -> Self {
Result {}
}
}
impl From<Result> for ResultProto {
fn from(_op: Result) -> Self {
ResultProto {}
}
}
#[cfg(test)]
mod test {
use super::super::generated_ops::delete_client::Operation as OperationProto;
use crate::operations::delete_client::Operation;
#[test]
fn proto_to_resp() {
let proto = OperationProto {
client: String::from("toto"),
};
let resp: Operation = proto.into();
assert_eq!(resp.client, String::from("toto"));
}
#[test]
fn resp_to_proto() {
let resp: Operation = Operation {
client: String::from("toto"),
};
let proto: OperationProto = resp.into();
assert_eq!(proto.client, String::from("toto"));
}
}