proxy_wasm/
types.rs

1// Copyright 2020 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//      http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use crate::traits::*;
16
17pub type NewRootContext = fn(context_id: u32) -> Box<dyn RootContext>;
18pub type NewStreamContext = fn(context_id: u32, root_context_id: u32) -> Box<dyn StreamContext>;
19pub type NewHttpContext = fn(context_id: u32, root_context_id: u32) -> Box<dyn HttpContext>;
20
21#[repr(u32)]
22#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
23pub enum LogLevel {
24    Trace = 0,
25    Debug = 1,
26    Info = 2,
27    Warn = 3,
28    Error = 4,
29    Critical = 5,
30}
31
32#[repr(u32)]
33#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
34#[non_exhaustive]
35pub enum Action {
36    Continue = 0,
37    Pause = 1,
38}
39
40#[repr(u32)]
41#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
42#[non_exhaustive]
43pub enum Status {
44    Ok = 0,
45    NotFound = 1,
46    BadArgument = 2,
47    SerializationFailure = 3,
48    ParseFailure = 4,
49    Empty = 7,
50    CasMismatch = 8,
51    InternalFailure = 10,
52}
53
54#[repr(u32)]
55#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
56#[non_exhaustive]
57pub enum ContextType {
58    HttpContext = 0,
59    StreamContext = 1,
60}
61
62#[repr(u32)]
63#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
64#[non_exhaustive]
65pub enum StreamType {
66    HttpRequest = 0,
67    HttpResponse = 1,
68    Downstream = 2,
69    Upstream = 3,
70}
71
72#[repr(u32)]
73#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
74#[non_exhaustive]
75pub enum BufferType {
76    HttpRequestBody = 0,
77    HttpResponseBody = 1,
78    DownstreamData = 2,
79    UpstreamData = 3,
80    HttpCallResponseBody = 4,
81    GrpcReceiveBuffer = 5,
82    VmConfiguration = 6,
83    PluginConfiguration = 7,
84}
85
86#[repr(u32)]
87#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
88#[non_exhaustive]
89pub enum MapType {
90    HttpRequestHeaders = 0,
91    HttpRequestTrailers = 1,
92    HttpResponseHeaders = 2,
93    HttpResponseTrailers = 3,
94    GrpcReceiveInitialMetadata = 4,
95    GrpcReceiveTrailingMetadata = 5,
96    HttpCallResponseHeaders = 6,
97    HttpCallResponseTrailers = 7,
98}
99
100#[repr(u32)]
101#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
102#[non_exhaustive]
103pub enum PeerType {
104    Unknown = 0,
105    Local = 1,
106    Remote = 2,
107}
108
109#[repr(u32)]
110#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
111#[non_exhaustive]
112pub enum MetricType {
113    Counter = 0,
114    Gauge = 1,
115    Histogram = 2,
116}
117
118#[repr(u32)]
119#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
120#[non_exhaustive]
121pub enum GrpcStatusCode {
122    Ok = 0,
123    Cancelled = 1,
124    Unknown = 2,
125    InvalidArgument = 3,
126    DeadlineExceeded = 4,
127    NotFound = 5,
128    AlreadyExists = 6,
129    PermissionDenied = 7,
130    ResourceExhausted = 8,
131    FailedPrecondition = 9,
132    Aborted = 10,
133    OutOfRange = 11,
134    Unimplemented = 12,
135    Internal = 13,
136    Unavailable = 14,
137    DataLoss = 15,
138    Unauthenticated = 16,
139}
140
141pub type Bytes = Vec<u8>;