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    CallData = 8,
85}
86
87#[repr(u32)]
88#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
89#[non_exhaustive]
90pub enum MapType {
91    HttpRequestHeaders = 0,
92    HttpRequestTrailers = 1,
93    HttpResponseHeaders = 2,
94    HttpResponseTrailers = 3,
95    GrpcReceiveInitialMetadata = 4,
96    GrpcReceiveTrailingMetadata = 5,
97    HttpCallResponseHeaders = 6,
98    HttpCallResponseTrailers = 7,
99}
100
101#[repr(u32)]
102#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
103#[non_exhaustive]
104pub enum PeerType {
105    Unknown = 0,
106    Local = 1,
107    Remote = 2,
108}
109
110#[repr(u32)]
111#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
112#[non_exhaustive]
113pub enum MetricType {
114    Counter = 0,
115    Gauge = 1,
116    Histogram = 2,
117}
118
119#[repr(u32)]
120#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
121#[non_exhaustive]
122pub enum GrpcStatusCode {
123    Ok = 0,
124    Cancelled = 1,
125    Unknown = 2,
126    InvalidArgument = 3,
127    DeadlineExceeded = 4,
128    NotFound = 5,
129    AlreadyExists = 6,
130    PermissionDenied = 7,
131    ResourceExhausted = 8,
132    FailedPrecondition = 9,
133    Aborted = 10,
134    OutOfRange = 11,
135    Unimplemented = 12,
136    Internal = 13,
137    Unavailable = 14,
138    DataLoss = 15,
139    Unauthenticated = 16,
140}
141
142pub type Bytes = Vec<u8>;