Skip to content

Commit 2a83c60

Browse files
committed
types: derive common traits and mark Status as non-exhaustive
Signed-off-by: Alejandro Martinez Ruiz <[email protected]>
1 parent b19b85a commit 2a83c60

File tree

1 file changed

+32
-29
lines changed

1 file changed

+32
-29
lines changed

src/types.rs

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub type NewStreamContext = fn(context_id: u32, root_context_id: u32) -> Box<dyn
1919
pub type NewHttpContext = fn(context_id: u32, root_context_id: u32) -> Box<dyn HttpContext>;
2020

2121
#[repr(u32)]
22-
#[derive(Debug)]
22+
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
2323
pub enum LogLevel {
2424
Trace = 0,
2525
Debug = 1,
@@ -30,14 +30,14 @@ pub enum LogLevel {
3030
}
3131

3232
#[repr(u32)]
33-
#[derive(Debug)]
33+
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
3434
pub enum FilterStatus {
3535
Continue = 0,
3636
StopIteration = 1,
3737
}
3838

3939
#[repr(u32)]
40-
#[derive(Debug)]
40+
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
4141
pub enum FilterHeadersStatus {
4242
Continue = 0,
4343
StopIteration = 1,
@@ -47,20 +47,20 @@ pub enum FilterHeadersStatus {
4747
}
4848

4949
#[repr(u32)]
50-
#[derive(Debug)]
50+
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
5151
pub enum FilterMetadataStatus {
5252
Continue = 0,
5353
}
5454

5555
#[repr(u32)]
56-
#[derive(Debug)]
56+
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
5757
pub enum FilterTrailersStatus {
5858
Continue = 0,
5959
StopIteration = 1,
6060
}
6161

6262
#[repr(u32)]
63-
#[derive(Debug)]
63+
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
6464
pub enum FilterDataStatus {
6565
Continue = 0,
6666
StopIterationAndBuffer = 1,
@@ -69,25 +69,7 @@ pub enum FilterDataStatus {
6969
}
7070

7171
#[repr(u32)]
72-
#[derive(Debug)]
73-
pub enum Status {
74-
Ok = 0,
75-
NotFound = 1,
76-
BadArgument = 2,
77-
SerializationFailure = 3,
78-
ParseFailure = 4,
79-
BadExpression = 5,
80-
InvalidMemoryAccess = 6,
81-
Empty = 7,
82-
CasMismatch = 8,
83-
ResultMismatch = 9,
84-
InternalFailure = 10,
85-
BrokenConnection = 11,
86-
Unimplemented = 12,
87-
}
88-
89-
#[repr(u32)]
90-
#[derive(Debug)]
72+
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
9173
pub enum BufferType {
9274
HttpRequestBody = 0,
9375
HttpResponseBody = 1,
@@ -101,7 +83,7 @@ pub enum BufferType {
10183
}
10284

10385
#[repr(u32)]
104-
#[derive(Debug)]
86+
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
10587
pub enum MapType {
10688
HttpRequestHeaders = 0,
10789
HttpRequestTrailers = 1,
@@ -114,15 +96,15 @@ pub enum MapType {
11496
}
11597

11698
#[repr(u32)]
117-
#[derive(Debug)]
99+
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
118100
pub enum PeerType {
119101
Unknown = 0,
120102
Local = 1,
121103
Remote = 2,
122104
}
123105

124106
#[repr(u32)]
125-
#[derive(Debug)]
107+
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
126108
pub enum MetricType {
127109
Counter = 0,
128110
Gauge = 1,
@@ -132,8 +114,29 @@ pub enum MetricType {
132114
pub type Bytes = Vec<u8>;
133115

134116
#[repr(u32)]
135-
#[derive(Debug)]
117+
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
136118
pub enum StreamType {
137119
Request = 0,
138120
Response = 1,
139121
}
122+
123+
// This is returned by the ABI and subject to additions, so make it
124+
// non exhaustive.
125+
#[repr(u32)]
126+
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
127+
#[non_exhaustive]
128+
pub enum Status {
129+
Ok = 0,
130+
NotFound = 1,
131+
BadArgument = 2,
132+
SerializationFailure = 3,
133+
ParseFailure = 4,
134+
BadExpression = 5,
135+
InvalidMemoryAccess = 6,
136+
Empty = 7,
137+
CasMismatch = 8,
138+
ResultMismatch = 9,
139+
InternalFailure = 10,
140+
BrokenConnection = 11,
141+
Unimplemented = 12,
142+
}

0 commit comments

Comments
 (0)