proxy_wasm_experimental/
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 use crate::bytestring::ByteString;
18
19pub type NewRootContext = fn(context_id: u32) -> Box<dyn RootContext>;
20pub type NewStreamContext = fn(context_id: u32, root_context_id: u32) -> Box<dyn StreamContext>;
21pub type NewHttpContext = fn(context_id: u32, root_context_id: u32) -> Box<dyn HttpContext>;
22
23#[repr(u32)]
24#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
25pub enum LogLevel {
26    Trace = 0,
27    Debug = 1,
28    Info = 2,
29    Warn = 3,
30    Error = 4,
31    Critical = 5,
32}
33
34#[repr(u32)]
35#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
36pub enum Action {
37    Continue = 0,
38    Pause = 1,
39}
40
41#[repr(u32)]
42#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
43pub enum Status {
44    Ok = 0,
45    NotFound = 1,
46    BadArgument = 2,
47    Empty = 7,
48    CasMismatch = 8,
49    InternalFailure = 10,
50}
51
52#[repr(u32)]
53#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
54pub enum ContextType {
55    HttpContext = 0,
56    StreamContext = 1,
57}
58
59#[repr(u32)]
60#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
61pub enum BufferType {
62    HttpRequestBody = 0,
63    HttpResponseBody = 1,
64    DownstreamData = 2,
65    UpstreamData = 3,
66    HttpCallResponseBody = 4, // Immutable
67    GrpcReceiveBuffer = 5,    // Immutable
68    VmConfiguration = 6,      // Immutable
69    PluginConfiguration = 7,  // Immutable
70    CallData = 8,             // Immutable
71}
72
73#[repr(u32)]
74#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
75pub enum MapType {
76    HttpRequestHeaders = 0,
77    HttpRequestTrailers = 1,
78    HttpResponseHeaders = 2,
79    HttpResponseTrailers = 3,
80    GrpcReceiveInitialMetadata = 4,  // Immutable
81    GrpcReceiveTrailingMetadata = 5, // Immutable
82    HttpCallResponseHeaders = 6,     // Immutable
83    HttpCallResponseTrailers = 7,    // Immutable
84}
85
86#[repr(u32)]
87#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
88pub enum PeerType {
89    Unknown = 0,
90    Local = 1,
91    Remote = 2,
92}
93
94#[repr(u32)]
95#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
96pub enum StreamType {
97    Request = 0,
98    Response = 1,
99}
100
101#[repr(u32)]
102#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
103pub enum MetricType {
104    Counter = 0,
105    Gauge = 1,
106    Histogram = 2,
107}