pilota_build/middle/ext/
mod.rs1pub mod pb;
2
3#[derive(Clone, Debug, PartialEq, Eq, Hash)]
6pub enum FileExts {
7 Pb(pb::FileExts),
8 Thrift,
9}
10
11impl FileExts {
12 pub fn has_extendees(&self) -> bool {
13 match self {
14 FileExts::Pb(pb::FileExts { extendees, .. }) => !extendees.is_empty(),
15 FileExts::Thrift => false,
16 }
17 }
18
19 pub fn has_used_options(&self) -> bool {
20 match self {
21 FileExts::Pb(pb::FileExts { used_options, .. }) => !used_options.is_empty(),
22 FileExts::Thrift => false,
23 }
24 }
25
26 pub fn unwrap_as_pb(&self) -> &pb::FileExts {
27 match self {
28 FileExts::Pb(exts) => exts,
29 FileExts::Thrift => unreachable!(),
30 }
31 }
32}
33
34#[derive(Clone, Debug, PartialEq, Eq, Hash)]
37pub enum ModExts {
38 Pb(pb::ModExts),
39 Thrift,
40}
41
42impl ModExts {
43 pub fn has_extendees(&self) -> bool {
44 match self {
45 ModExts::Pb(pb::ModExts { extendees }) => !extendees.is_empty(),
46 ModExts::Thrift => false,
47 }
48 }
49
50 pub fn unwrap_as_pb(&self) -> &pb::ModExts {
51 match self {
52 ModExts::Pb(exts) => exts,
53 ModExts::Thrift => unreachable!(),
54 }
55 }
56}
57
58#[derive(Clone, Debug, PartialEq, Eq, Hash)]
61pub enum ItemExts {
62 Pb(pb::ItemExts),
63 Thrift,
64}
65
66impl ItemExts {
67 pub fn has_used_options(&self) -> bool {
68 match self {
69 ItemExts::Pb(pb::ItemExts { used_options, .. }) => !used_options.is_empty(),
70 ItemExts::Thrift => false,
71 }
72 }
73
74 pub fn unwrap_as_pb(&self) -> &pb::ItemExts {
75 match self {
76 ItemExts::Pb(exts) => exts,
77 ItemExts::Thrift => unreachable!(),
78 }
79 }
80}