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
use reflect::EnumDescriptor;
use reflect::EnumValueDescriptor;
pub trait ProtobufEnum: Eq + Sized + Copy + 'static {
fn value(&self) -> i32;
fn from_i32(v: i32) -> Option<Self>;
fn values() -> &'static [Self] {
panic!();
}
fn descriptor(&self) -> &'static EnumValueDescriptor {
self.enum_descriptor().value_by_number(self.value())
}
fn enum_descriptor(&self) -> &'static EnumDescriptor {
Self::enum_descriptor_static()
}
fn enum_descriptor_static() -> &'static EnumDescriptor {
panic!();
}
}