From 594405b042f091a138e8fdcddf97ad9cf7de2bc5 Mon Sep 17 00:00:00 2001 From: Campbell He Date: Sat, 11 May 2024 12:52:39 +0000 Subject: [PATCH] Add generated rust code The rust code is generated using the [`neoeinstein/protoc-gen-prost`](https://github.com/neoeinstein/protoc-gen-prost), which leverages the `prost` crate for protobuf and `tonic` crate for client/server. The rust crates used are: pbjson and pbjson-types: 0.7.0 prost: 0.13.1 tonic: 0.12.0 Currently, the generated code does not use `protoc-prost-serde` to support serde, since serde and json deserialization is not necessary for the basic use case. --- .gitignore | 3 + CI/check_codegen.sh | 9 + README.md | 19 +- codegen/Dockerfile | 8 +- codegen/compile_protos.sh | 11 + codegen/update.sh | 3 + rust/Cargo.lock | 1195 ++++++++++++++++++++++++++++++++ rust/Cargo.toml | 27 + rust/LICENSE | 1 + rust/README.md | 1 + rust/src/google.rpc.rs | 226 +++++++ rust/src/lib.rs | 25 + rust/src/p4.config.v1.rs | 1231 +++++++++++++++++++++++++++++++++ rust/src/p4.v1.rs | 1351 +++++++++++++++++++++++++++++++++++++ rust/src/p4.v1.tonic.rs | 703 +++++++++++++++++++ 15 files changed, 4808 insertions(+), 5 deletions(-) create mode 100644 rust/Cargo.lock create mode 100644 rust/Cargo.toml create mode 120000 rust/LICENSE create mode 120000 rust/README.md create mode 100644 rust/src/google.rpc.rs create mode 100644 rust/src/lib.rs create mode 100644 rust/src/p4.config.v1.rs create mode 100644 rust/src/p4.v1.rs create mode 100644 rust/src/p4.v1.tonic.rs diff --git a/.gitignore b/.gitignore index 06bc82c5..8af80faf 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,6 @@ build dist *.egg-info .eggs + +# rust +target/ diff --git a/CI/check_codegen.sh b/CI/check_codegen.sh index bf820056..b87bd005 100755 --- a/CI/check_codegen.sh +++ b/CI/check_codegen.sh @@ -8,6 +8,7 @@ pushd "$THIS_DIR/.." >/dev/null rm -rf go/* rm -rf py/p4 +rm -rf rust/src ./codegen/update.sh diff="$(git status --porcelain go go.mod go.sum)" @@ -26,4 +27,12 @@ if [ ! -z "$diff" ]; then exit 1 fi +diff="$(git status --porcelain rust)" + +if [ ! -z "$diff" ]; then + echo "The generated Rust files are not up-to-date" + echo "You can regenerate them with './codegen/update.sh' and commit the changes" + exit 1 +fi + popd >/dev/null diff --git a/README.md b/README.md index 250c6553..41cb9c05 100644 --- a/README.md +++ b/README.md @@ -145,10 +145,11 @@ processes. approve. When updating the Protobuf files in a pull request, you will also need to update -the generated Go and Python files, which are hosted in this repository under -[go/](go/) and [py/](py/). This can be done easily by running `./codegen/update.sh`, -provided docker is installed and your user is part of the "docker" group -(which means that the `docker` command can be executed without `sudo`). +the generated Go, Python and Rust files, which are hosted in this repository +under [go/](go/), [py/](py/) and [rust/](rust/). This can be done easily by +running `./codegen/update.sh`, provided docker is installed and your user is +part of the "docker" group (which means that the `docker` command can be +executed without `sudo`). ## Use generated P4Runtime library @@ -177,6 +178,16 @@ pip3 install p4runtime pip3 install p4runtime==1.3.0 ``` +### Rust + +To include the P4Runtime Rust crate to your project, add this repository url to +your `Cargo.toml` file: + +```toml +[dependencies] +p4runtime = { git = "https://github.com/p4lang/p4runtime.git" } +``` + ## Guidelines for using Protocol Buffers (protobuf) in backwards-compatible ways P4Runtime generally follows "Live at Head" development principles - new diff --git a/codegen/Dockerfile b/codegen/Dockerfile index 46e940d2..1e8dfb75 100644 --- a/codegen/Dockerfile +++ b/codegen/Dockerfile @@ -6,7 +6,7 @@ LABEL description="Dockerfile used for CI testing of p4lang/p4runtime" ARG DEBIAN_FRONTEND=noninteractive RUN apt-get update && \ - apt-get install -y --no-install-recommends software-properties-common git curl + apt-get install -y --no-install-recommends software-properties-common git curl build-essential ARG GO_VERSION=1.20.5 @@ -26,5 +26,11 @@ ENV PATH="${PATH}:/usr/local/go/bin:/root/go/bin" RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.31 RUN go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.3 +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable --profile minimal; \ + . $HOME/.cargo/env; \ + cargo install protoc-gen-prost protoc-gen-prost-crate protoc-gen-prost-serde protoc-gen-tonic + +ENV PATH="${PATH}:/root/.cargo/bin" + COPY . /p4runtime/ WORKDIR /p4runtime/ diff --git a/codegen/compile_protos.sh b/codegen/compile_protos.sh index 37bb7d02..486e21f9 100755 --- a/codegen/compile_protos.sh +++ b/codegen/compile_protos.sh @@ -53,6 +53,7 @@ mkdir -p "$BUILD_DIR/cpp_out" mkdir -p "$BUILD_DIR/grpc_out" mkdir -p "$BUILD_DIR/py_out" mkdir -p "$BUILD_DIR/go_out" +mkdir -p "$BUILD_DIR/rust_out" set -o xtrace $PROTOC $PROTOS --cpp_out "$BUILD_DIR/cpp_out" $PROTOFLAGS @@ -65,6 +66,16 @@ $PROTOC $PROTOS --python_out "$BUILD_DIR/py_out" $PROTOFLAGS --grpc_out "$BUILD_ $PROTOC $PROTOS --go_out="$BUILD_DIR/go_out" --go-grpc_out="$BUILD_DIR/go_out" $PROTOFLAGS +$PROTOC $PROTOS $PROTOFLAGS \ + --prost_out="$BUILD_DIR/rust_out/src" \ + --prost_opt=compile_well_known_types \ + --prost_opt=extern_path=.google.protobuf=::pbjson_types \ + --tonic_out="$BUILD_DIR/rust_out/src" \ + --tonic_opt=compile_well_known_types \ + --tonic_opt=extern_path=.google.protobuf=::pbjson_types \ + --prost-crate_out="$BUILD_DIR/rust_out" \ + --prost-crate_opt="gen_crate=rust/Cargo.toml" + set +o xtrace rm -rf "$tmpdir" diff --git a/codegen/update.sh b/codegen/update.sh index aa8b1772..084bc07c 100755 --- a/codegen/update.sh +++ b/codegen/update.sh @@ -21,6 +21,9 @@ cp -r "$tmpdir"/go_out/github.com/p4lang/p4runtime/go/* go/ cp -r "$tmpdir"/py_out/p4 py/ find py/p4 -type d -exec touch {}/__init__.py \; +# Rust +cp -r "$tmpdir"/rust_out/* rust/ + # Cleanup files owned by root user docker run --rm \ -v "$tmpdir:/tmp/gen" \ diff --git a/rust/Cargo.lock b/rust/Cargo.lock new file mode 100644 index 00000000..a82b6173 --- /dev/null +++ b/rust/Cargo.lock @@ -0,0 +1,1195 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "addr2line" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "anyhow" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" + +[[package]] +name = "async-stream" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51" +dependencies = [ + "async-stream-impl", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "async-trait" +version = "0.1.81" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + +[[package]] +name = "autocfg" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" + +[[package]] +name = "axum" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a6c9af12842a67734c9a2e355436e5d03b22383ed60cf13cd0c18fbfe3dcbcf" +dependencies = [ + "async-trait", + "axum-core", + "bytes", + "futures-util", + "http", + "http-body", + "http-body-util", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "rustversion", + "serde", + "sync_wrapper 1.0.1", + "tower", + "tower-layer", + "tower-service", +] + +[[package]] +name = "axum-core" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a15c63fd72d41492dc4f497196f5da1fb04fb7529e631d73630d1b491e47a2e3" +dependencies = [ + "async-trait", + "bytes", + "futures-util", + "http", + "http-body", + "http-body-util", + "mime", + "pin-project-lite", + "rustversion", + "sync_wrapper 0.1.2", + "tower-layer", + "tower-service", +] + +[[package]] +name = "backtrace" +version = "0.3.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] +name = "base64" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "bitflags" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" + +[[package]] +name = "bytes" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" + +[[package]] +name = "cc" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eaff6f8ce506b9773fa786672d63fc7a191ffea1be33f72bbd4aeacefca9ffc8" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chrono" +version = "0.4.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +dependencies = [ + "num-traits", +] + +[[package]] +name = "either" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "errno" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "fastrand" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" + +[[package]] +name = "fixedbitset" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "futures-channel" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" + +[[package]] +name = "futures-sink" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" + +[[package]] +name = "futures-task" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" + +[[package]] +name = "futures-util" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +dependencies = [ + "futures-core", + "futures-task", + "pin-project-lite", + "pin-utils", +] + +[[package]] +name = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "gimli" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" + +[[package]] +name = "h2" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa82e28a107a8cc405f0839610bdc9b15f1e25ec7d696aa5cf173edbcb1486ab" +dependencies = [ + "atomic-waker", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "http", + "indexmap 2.2.6", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "http" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" +dependencies = [ + "bytes", + "futures-util", + "http", + "http-body", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "hyper" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50dfd22e0e76d0f662d429a5f80fcaf3855009297eab6a0a9f8543834744ba05" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-timeout" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3203a961e5c83b6f5498933e78b6b263e208c197b63e9c6c53cc82ffd3f63793" +dependencies = [ + "hyper", + "hyper-util", + "pin-project-lite", + "tokio", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ab92f4f49ee4fb4f997c784b7a2e0fa70050211e0b6a287f898c3c9785ca956" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "hyper", + "pin-project-lite", + "socket2", + "tokio", + "tower", + "tower-service", + "tracing", +] + +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", +] + +[[package]] +name = "indexmap" +version = "2.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +dependencies = [ + "equivalent", + "hashbrown 0.14.5", +] + +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] +name = "libc" +version = "0.2.155" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" + +[[package]] +name = "linux-raw-sys" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" + +[[package]] +name = "log" +version = "0.4.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" + +[[package]] +name = "matchit" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "miniz_oxide" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" +dependencies = [ + "adler", +] + +[[package]] +name = "mio" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.48.0", +] + +[[package]] +name = "multimap" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "defc4c55412d89136f966bbb339008b474350e5e6e78d2714439c386b3137a03" + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "object" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "081b846d1d56ddfc18fdf1a922e4f6e07a11768ea1b92dec44e42b72712ccfce" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "p4runtime" +version = "1.4.0-rc.5" +dependencies = [ + "pbjson", + "pbjson-types", + "prost", + "tonic", +] + +[[package]] +name = "pbjson" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7e6349fa080353f4a597daffd05cb81572a9c031a6d4fff7e504947496fcc68" +dependencies = [ + "base64 0.21.7", + "serde", +] + +[[package]] +name = "pbjson-build" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6eea3058763d6e656105d1403cb04e0a41b7bbac6362d413e7c33be0c32279c9" +dependencies = [ + "heck", + "itertools", + "prost", + "prost-types", +] + +[[package]] +name = "pbjson-types" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e54e5e7bfb1652f95bc361d76f3c780d8e526b134b85417e774166ee941f0887" +dependencies = [ + "bytes", + "chrono", + "pbjson", + "pbjson-build", + "prost", + "prost-build", + "serde", +] + +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + +[[package]] +name = "petgraph" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" +dependencies = [ + "fixedbitset", + "indexmap 2.2.6", +] + +[[package]] +name = "pin-project" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "prettyplease" +version = "0.2.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" +dependencies = [ + "proc-macro2", + "syn", +] + +[[package]] +name = "proc-macro2" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "prost" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13db3d3fde688c61e2446b4d843bc27a7e8af269a69440c0308021dc92333cc" +dependencies = [ + "bytes", + "prost-derive", +] + +[[package]] +name = "prost-build" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5bb182580f71dd070f88d01ce3de9f4da5021db7115d2e1c3605a754153b77c1" +dependencies = [ + "bytes", + "heck", + "itertools", + "log", + "multimap", + "once_cell", + "petgraph", + "prettyplease", + "prost", + "prost-types", + "regex", + "syn", + "tempfile", +] + +[[package]] +name = "prost-derive" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18bec9b0adc4eba778b33684b7ba3e7137789434769ee3ce3930463ef904cfca" +dependencies = [ + "anyhow", + "itertools", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "prost-types" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cee5168b05f49d4b0ca581206eb14a7b22fafd963efe729ac48eb03266e25cc2" +dependencies = [ + "prost", +] + +[[package]] +name = "quote" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "regex" +version = "1.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" + +[[package]] +name = "rustc-demangle" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" + +[[package]] +name = "rustix" +version = "0.38.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustversion" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" + +[[package]] +name = "serde" +version = "1.0.204" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.204" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + +[[package]] +name = "socket2" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "syn" +version = "2.0.70" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f0209b68b3613b093e0ec905354eccaedcfe83b8cb37cbdeae64026c3064c16" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync_wrapper" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" + +[[package]] +name = "sync_wrapper" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" + +[[package]] +name = "tempfile" +version = "3.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" +dependencies = [ + "cfg-if", + "fastrand", + "rustix", + "windows-sys 0.52.0", +] + +[[package]] +name = "tokio" +version = "1.38.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba4f4a02a7a80d6f274636f0aa95c7e383b912d41fe721a31f29e29698585a4a" +dependencies = [ + "backtrace", + "bytes", + "libc", + "mio", + "pin-project-lite", + "socket2", + "tokio-macros", + "windows-sys 0.48.0", +] + +[[package]] +name = "tokio-macros" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio-stream" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "267ac89e0bec6e691e5813911606935d77c476ff49024f98abcea3e7b15e37af" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tonic" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f738b6a169a29bca4e39656db89c44a08e09c5b700b896ee9e7459f0652e81dd" +dependencies = [ + "async-stream", + "async-trait", + "axum", + "base64 0.22.1", + "bytes", + "h2", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-timeout", + "hyper-util", + "percent-encoding", + "pin-project", + "prost", + "socket2", + "tokio", + "tokio-stream", + "tower", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +dependencies = [ + "futures-core", + "futures-util", + "indexmap 1.9.3", + "pin-project", + "pin-project-lite", + "rand", + "slab", + "tokio", + "tokio-util", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-layer" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" + +[[package]] +name = "tower-service" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + +[[package]] +name = "tracing" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +dependencies = [ + "once_cell", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" diff --git a/rust/Cargo.toml b/rust/Cargo.toml new file mode 100644 index 00000000..aa44dfa8 --- /dev/null +++ b/rust/Cargo.toml @@ -0,0 +1,27 @@ +[package] +name = "p4runtime" +version = "1.4.0-rc.5" +edition = "2021" +authors = ["P4 API Working Group "] +description = "P4Runtime Specification" +categories = ["network-programming"] +keywords = ["p4runtime", "grpc"] +license = "Apache-2.0" +repository = "https://github.com/p4lang/p4runtime" + +[dependencies] +pbjson = "0.7.0" +pbjson-types = "0.7.0" +prost = "0.13.1" +tonic = "0.12.0" + +[features] +default = ["proto_full"] +# @@protoc_deletion_point(features) +# This section is automatically generated by protoc-gen-prost-crate. +# Changes in this area may be lost on regeneration. +proto_full = ["google-rpc","p4-config-v1","p4-v1"] +"google-rpc" = [] +"p4-config-v1" = [] +"p4-v1" = ["google-rpc","p4-config-v1"] +## @@protoc_insertion_point(features) diff --git a/rust/LICENSE b/rust/LICENSE new file mode 120000 index 00000000..ea5b6064 --- /dev/null +++ b/rust/LICENSE @@ -0,0 +1 @@ +../LICENSE \ No newline at end of file diff --git a/rust/README.md b/rust/README.md new file mode 120000 index 00000000..32d46ee8 --- /dev/null +++ b/rust/README.md @@ -0,0 +1 @@ +../README.md \ No newline at end of file diff --git a/rust/src/google.rpc.rs b/rust/src/google.rpc.rs new file mode 100644 index 00000000..cfb26b3f --- /dev/null +++ b/rust/src/google.rpc.rs @@ -0,0 +1,226 @@ +// @generated +// This file is @generated by prost-build. +/// The `Status` type defines a logical error model that is suitable for +/// different programming environments, including REST APIs and RPC APIs. It is +/// used by [gRPC](). Each `Status` message contains +/// three pieces of data: error code, error message, and error details. +/// +/// You can find out more about this error model and how to work with it in the +/// [API Design Guide](). +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Status { + /// The status code, which should be an enum value of + /// [google.rpc.Code][google.rpc.Code]. + #[prost(int32, tag="1")] + pub code: i32, + /// A developer-facing error message, which should be in English. Any + /// user-facing error message should be localized and sent in the + /// [google.rpc.Status.details][google.rpc.Status.details] field, or localized + /// by the client. + #[prost(string, tag="2")] + pub message: ::prost::alloc::string::String, + /// A list of messages that carry the error details. There is a common set of + /// message types for APIs to use. + #[prost(message, repeated, tag="3")] + pub details: ::prost::alloc::vec::Vec<::pbjson_types::Any>, +} +/// The canonical error codes for gRPC APIs. +/// +/// +/// Sometimes multiple error codes may apply. Services should return +/// the most specific error code that applies. For example, prefer +/// `OUT_OF_RANGE` over `FAILED_PRECONDITION` if both codes apply. +/// Similarly prefer `NOT_FOUND` or `ALREADY_EXISTS` over `FAILED_PRECONDITION`. +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum Code { + /// Not an error; returned on success. + /// + /// HTTP Mapping: 200 OK + Ok = 0, + /// The operation was cancelled, typically by the caller. + /// + /// HTTP Mapping: 499 Client Closed Request + Cancelled = 1, + /// Unknown error. For example, this error may be returned when + /// a `Status` value received from another address space belongs to + /// an error space that is not known in this address space. Also + /// errors raised by APIs that do not return enough error information + /// may be converted to this error. + /// + /// HTTP Mapping: 500 Internal Server Error + Unknown = 2, + /// The client specified an invalid argument. Note that this differs + /// from `FAILED_PRECONDITION`. `INVALID_ARGUMENT` indicates arguments + /// that are problematic regardless of the state of the system + /// (e.g., a malformed file name). + /// + /// HTTP Mapping: 400 Bad Request + InvalidArgument = 3, + /// The deadline expired before the operation could complete. For operations + /// that change the state of the system, this error may be returned + /// even if the operation has completed successfully. For example, a + /// successful response from a server could have been delayed long + /// enough for the deadline to expire. + /// + /// HTTP Mapping: 504 Gateway Timeout + DeadlineExceeded = 4, + /// Some requested entity (e.g., file or directory) was not found. + /// + /// Note to server developers: if a request is denied for an entire class + /// of users, such as gradual feature rollout or undocumented allowlist, + /// `NOT_FOUND` may be used. If a request is denied for some users within + /// a class of users, such as user-based access control, `PERMISSION_DENIED` + /// must be used. + /// + /// HTTP Mapping: 404 Not Found + NotFound = 5, + /// The entity that a client attempted to create (e.g., file or directory) + /// already exists. + /// + /// HTTP Mapping: 409 Conflict + AlreadyExists = 6, + /// The caller does not have permission to execute the specified + /// operation. `PERMISSION_DENIED` must not be used for rejections + /// caused by exhausting some resource (use `RESOURCE_EXHAUSTED` + /// instead for those errors). `PERMISSION_DENIED` must not be + /// used if the caller can not be identified (use `UNAUTHENTICATED` + /// instead for those errors). This error code does not imply the + /// request is valid or the requested entity exists or satisfies + /// other pre-conditions. + /// + /// HTTP Mapping: 403 Forbidden + PermissionDenied = 7, + /// The request does not have valid authentication credentials for the + /// operation. + /// + /// HTTP Mapping: 401 Unauthorized + Unauthenticated = 16, + /// Some resource has been exhausted, perhaps a per-user quota, or + /// perhaps the entire file system is out of space. + /// + /// HTTP Mapping: 429 Too Many Requests + ResourceExhausted = 8, + /// The operation was rejected because the system is not in a state + /// required for the operation's execution. For example, the directory + /// to be deleted is non-empty, an rmdir operation is applied to + /// a non-directory, etc. + /// + /// Service implementors can use the following guidelines to decide + /// between `FAILED_PRECONDITION`, `ABORTED`, and `UNAVAILABLE`: + /// (a) Use `UNAVAILABLE` if the client can retry just the failing call. + /// (b) Use `ABORTED` if the client should retry at a higher level. For + /// example, when a client-specified test-and-set fails, indicating the + /// client should restart a read-modify-write sequence. + /// (c) Use `FAILED_PRECONDITION` if the client should not retry until + /// the system state has been explicitly fixed. For example, if an "rmdir" + /// fails because the directory is non-empty, `FAILED_PRECONDITION` + /// should be returned since the client should not retry unless + /// the files are deleted from the directory. + /// + /// HTTP Mapping: 400 Bad Request + FailedPrecondition = 9, + /// The operation was aborted, typically due to a concurrency issue such as + /// a sequencer check failure or transaction abort. + /// + /// See the guidelines above for deciding between `FAILED_PRECONDITION`, + /// `ABORTED`, and `UNAVAILABLE`. + /// + /// HTTP Mapping: 409 Conflict + Aborted = 10, + /// The operation was attempted past the valid range. E.g., seeking or + /// reading past end-of-file. + /// + /// Unlike `INVALID_ARGUMENT`, this error indicates a problem that may + /// be fixed if the system state changes. For example, a 32-bit file + /// system will generate `INVALID_ARGUMENT` if asked to read at an + /// offset that is not in the range \[0,2^32-1\], but it will generate + /// `OUT_OF_RANGE` if asked to read from an offset past the current + /// file size. + /// + /// There is a fair bit of overlap between `FAILED_PRECONDITION` and + /// `OUT_OF_RANGE`. We recommend using `OUT_OF_RANGE` (the more specific + /// error) when it applies so that callers who are iterating through + /// a space can easily look for an `OUT_OF_RANGE` error to detect when + /// they are done. + /// + /// HTTP Mapping: 400 Bad Request + OutOfRange = 11, + /// The operation is not implemented or is not supported/enabled in this + /// service. + /// + /// HTTP Mapping: 501 Not Implemented + Unimplemented = 12, + /// Internal errors. This means that some invariants expected by the + /// underlying system have been broken. This error code is reserved + /// for serious errors. + /// + /// HTTP Mapping: 500 Internal Server Error + Internal = 13, + /// The service is currently unavailable. This is most likely a + /// transient condition, which can be corrected by retrying with + /// a backoff. Note that it is not always safe to retry + /// non-idempotent operations. + /// + /// See the guidelines above for deciding between `FAILED_PRECONDITION`, + /// `ABORTED`, and `UNAVAILABLE`. + /// + /// HTTP Mapping: 503 Service Unavailable + Unavailable = 14, + /// Unrecoverable data loss or corruption. + /// + /// HTTP Mapping: 500 Internal Server Error + DataLoss = 15, +} +impl Code { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + Code::Ok => "OK", + Code::Cancelled => "CANCELLED", + Code::Unknown => "UNKNOWN", + Code::InvalidArgument => "INVALID_ARGUMENT", + Code::DeadlineExceeded => "DEADLINE_EXCEEDED", + Code::NotFound => "NOT_FOUND", + Code::AlreadyExists => "ALREADY_EXISTS", + Code::PermissionDenied => "PERMISSION_DENIED", + Code::Unauthenticated => "UNAUTHENTICATED", + Code::ResourceExhausted => "RESOURCE_EXHAUSTED", + Code::FailedPrecondition => "FAILED_PRECONDITION", + Code::Aborted => "ABORTED", + Code::OutOfRange => "OUT_OF_RANGE", + Code::Unimplemented => "UNIMPLEMENTED", + Code::Internal => "INTERNAL", + Code::Unavailable => "UNAVAILABLE", + Code::DataLoss => "DATA_LOSS", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "OK" => Some(Self::Ok), + "CANCELLED" => Some(Self::Cancelled), + "UNKNOWN" => Some(Self::Unknown), + "INVALID_ARGUMENT" => Some(Self::InvalidArgument), + "DEADLINE_EXCEEDED" => Some(Self::DeadlineExceeded), + "NOT_FOUND" => Some(Self::NotFound), + "ALREADY_EXISTS" => Some(Self::AlreadyExists), + "PERMISSION_DENIED" => Some(Self::PermissionDenied), + "UNAUTHENTICATED" => Some(Self::Unauthenticated), + "RESOURCE_EXHAUSTED" => Some(Self::ResourceExhausted), + "FAILED_PRECONDITION" => Some(Self::FailedPrecondition), + "ABORTED" => Some(Self::Aborted), + "OUT_OF_RANGE" => Some(Self::OutOfRange), + "UNIMPLEMENTED" => Some(Self::Unimplemented), + "INTERNAL" => Some(Self::Internal), + "UNAVAILABLE" => Some(Self::Unavailable), + "DATA_LOSS" => Some(Self::DataLoss), + _ => None, + } + } +} +// @@protoc_insertion_point(module) diff --git a/rust/src/lib.rs b/rust/src/lib.rs new file mode 100644 index 00000000..d4eeb294 --- /dev/null +++ b/rust/src/lib.rs @@ -0,0 +1,25 @@ +// @generated +pub mod google { + #[cfg(feature = "google-rpc")] + // @@protoc_insertion_point(attribute:google.rpc) + pub mod rpc { + include!("google.rpc.rs"); + // @@protoc_insertion_point(google.rpc) + } +} +pub mod p4 { + pub mod config { + #[cfg(feature = "p4-config-v1")] + // @@protoc_insertion_point(attribute:p4.config.v1) + pub mod v1 { + include!("p4.config.v1.rs"); + // @@protoc_insertion_point(p4.config.v1) + } + } + #[cfg(feature = "p4-v1")] + // @@protoc_insertion_point(attribute:p4.v1) + pub mod v1 { + include!("p4.v1.rs"); + // @@protoc_insertion_point(p4.v1) + } +} diff --git a/rust/src/p4.config.v1.rs b/rust/src/p4.config.v1.rs new file mode 100644 index 00000000..b8c2c3db --- /dev/null +++ b/rust/src/p4.config.v1.rs @@ -0,0 +1,1231 @@ +// @generated +// This file is @generated by prost-build. +// P4 type specs --------------------------------------------------------------- + +// From the P4_16 spec: + +// |--------------------|--------------------------------------------| +// | | Container type | +// | Element type |-----------|--------------|-----------------| +// | | header | header_union | struct or tuple | +// |--------------------|-----------|--------------|-----------------| +// | bit | allowed | error | allowed | +// | int | allowed | error | allowed | +// | varbit | allowed | error | allowed | +// | int | error | error | error | +// | void | error | error | error | +// | error | error | error | allowed | +// | match_kind | error | error | error | +// | bool | error | error | allowed | +// | enum | allowed* | error | allowed | +// | header | error | allowed | allowed | +// | header stack | error | error | allowed | +// | header_union | error | error | allowed | +// | struct | error | error | allowed | +// | tuple | error | error | allowed | +// |--------------------|-----------|--------------|-----------------| +// +// *if serializable + +/// These P4 types (struct, header_type, header_union and enum) are guaranteed to +/// have a fully-qualified name (e.g. you cannot use an anonymous struct to +/// declare a variable like in C). Instead of duplicating the type spec for these +/// every time the type is used, we include the type spec once in this P4TypeInfo +/// message and refer to the types by name in the P4DataTypeSpec message. We also +/// support annotations for these type specs which can be useful, e.g. to +/// identify well-known headers (such as ipv4). +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct P4TypeInfo { + #[prost(map="string, message", tag="1")] + pub structs: ::std::collections::HashMap<::prost::alloc::string::String, P4StructTypeSpec>, + #[prost(map="string, message", tag="2")] + pub headers: ::std::collections::HashMap<::prost::alloc::string::String, P4HeaderTypeSpec>, + #[prost(map="string, message", tag="3")] + pub header_unions: ::std::collections::HashMap<::prost::alloc::string::String, P4HeaderUnionTypeSpec>, + #[prost(map="string, message", tag="4")] + pub enums: ::std::collections::HashMap<::prost::alloc::string::String, P4EnumTypeSpec>, + #[prost(message, optional, tag="5")] + pub error: ::core::option::Option, + #[prost(map="string, message", tag="6")] + pub serializable_enums: ::std::collections::HashMap<::prost::alloc::string::String, P4SerializableEnumTypeSpec>, + #[prost(map="string, message", tag="7")] + pub new_types: ::std::collections::HashMap<::prost::alloc::string::String, P4NewTypeSpec>, +} +/// Describes a P4_16 type. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct P4DataTypeSpec { + #[prost(oneof="p4_data_type_spec::TypeSpec", tags="1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12")] + pub type_spec: ::core::option::Option, +} +/// Nested message and enum types in `P4DataTypeSpec`. +pub mod p4_data_type_spec { + #[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum TypeSpec { + #[prost(message, tag="1")] + Bitstring(super::P4BitstringLikeTypeSpec), + #[prost(message, tag="2")] + Bool(super::P4BoolType), + #[prost(message, tag="3")] + Tuple(super::P4TupleTypeSpec), + #[prost(message, tag="4")] + Struct(super::P4NamedType), + #[prost(message, tag="5")] + Header(super::P4NamedType), + #[prost(message, tag="6")] + HeaderUnion(super::P4NamedType), + #[prost(message, tag="7")] + HeaderStack(super::P4HeaderStackTypeSpec), + #[prost(message, tag="8")] + HeaderUnionStack(super::P4HeaderUnionStackTypeSpec), + #[prost(message, tag="9")] + Enum(super::P4NamedType), + #[prost(message, tag="10")] + Error(super::P4ErrorType), + #[prost(message, tag="11")] + SerializableEnum(super::P4NamedType), + #[prost(message, tag="12")] + NewType(super::P4NamedType), + } +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct P4NamedType { + #[prost(string, tag="1")] + pub name: ::prost::alloc::string::String, +} +/// Empty message as no type information needed, just used as a placeholder in +/// the oneof to identify boolean types. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct P4BoolType { +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct P4ErrorType { +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct P4BitstringLikeTypeSpec { + /// Useful to identify well-known types, such as IP address or Ethernet MAC + /// address. + #[prost(string, repeated, tag="4")] + pub annotations: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + /// Optional. If present, the location of `annotations\[i\]` is given by + /// `annotation_locations\[i\]`. + #[prost(message, repeated, tag="5")] + pub annotation_locations: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="6")] + pub structured_annotations: ::prost::alloc::vec::Vec, + #[prost(oneof="p4_bitstring_like_type_spec::TypeSpec", tags="1, 2, 3")] + pub type_spec: ::core::option::Option, +} +/// Nested message and enum types in `P4BitstringLikeTypeSpec`. +pub mod p4_bitstring_like_type_spec { + #[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum TypeSpec { + /// bit + #[prost(message, tag="1")] + Bit(super::P4BitTypeSpec), + /// int + #[prost(message, tag="2")] + Int(super::P4IntTypeSpec), + /// varbit + #[prost(message, tag="3")] + Varbit(super::P4VarbitTypeSpec), + } +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct P4BitTypeSpec { + #[prost(int32, tag="1")] + pub bitwidth: i32, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct P4IntTypeSpec { + #[prost(int32, tag="1")] + pub bitwidth: i32, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct P4VarbitTypeSpec { + #[prost(int32, tag="1")] + pub max_bitwidth: i32, +} +/// From the P4_16 spec: "A tuple is similar to a struct, in that it holds +/// multiple values. Unlike a struct type, tuples have no named fields." +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct P4TupleTypeSpec { + #[prost(message, repeated, tag="1")] + pub members: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct P4StructTypeSpec { + #[prost(message, repeated, tag="1")] + pub members: ::prost::alloc::vec::Vec, + #[prost(string, repeated, tag="2")] + pub annotations: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + /// Optional. If present, the location of `annotations\[i\]` is given by + /// `annotation_locations\[i\]`. + #[prost(message, repeated, tag="3")] + pub annotation_locations: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="4")] + pub structured_annotations: ::prost::alloc::vec::Vec, +} +/// Nested message and enum types in `P4StructTypeSpec`. +pub mod p4_struct_type_spec { + #[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] + pub struct Member { + #[prost(string, tag="1")] + pub name: ::prost::alloc::string::String, + #[prost(message, optional, tag="2")] + pub type_spec: ::core::option::Option, + } +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct P4HeaderTypeSpec { + #[prost(message, repeated, tag="1")] + pub members: ::prost::alloc::vec::Vec, + #[prost(string, repeated, tag="2")] + pub annotations: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + /// Optional. If present, the location of `annotations\[i\]` is given by + /// `annotation_locations\[i\]`. + #[prost(message, repeated, tag="3")] + pub annotation_locations: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="4")] + pub structured_annotations: ::prost::alloc::vec::Vec, +} +/// Nested message and enum types in `P4HeaderTypeSpec`. +pub mod p4_header_type_spec { + #[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] + pub struct Member { + #[prost(string, tag="1")] + pub name: ::prost::alloc::string::String, + #[prost(message, optional, tag="2")] + pub type_spec: ::core::option::Option, + } +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct P4HeaderUnionTypeSpec { + #[prost(message, repeated, tag="1")] + pub members: ::prost::alloc::vec::Vec, + #[prost(string, repeated, tag="2")] + pub annotations: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + /// Optional. If present, the location of `annotations\[i\]` is given by + /// `annotation_locations\[i\]`. + #[prost(message, repeated, tag="3")] + pub annotation_locations: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="4")] + pub structured_annotations: ::prost::alloc::vec::Vec, +} +/// Nested message and enum types in `P4HeaderUnionTypeSpec`. +pub mod p4_header_union_type_spec { + #[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] + pub struct Member { + #[prost(string, tag="1")] + pub name: ::prost::alloc::string::String, + #[prost(message, optional, tag="2")] + pub header: ::core::option::Option, + } +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct P4HeaderStackTypeSpec { + #[prost(message, optional, tag="1")] + pub header: ::core::option::Option, + #[prost(int32, tag="2")] + pub size: i32, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct P4HeaderUnionStackTypeSpec { + #[prost(message, optional, tag="1")] + pub header_union: ::core::option::Option, + #[prost(int32, tag="2")] + pub size: i32, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct KeyValuePair { + #[prost(string, tag="1")] + pub key: ::prost::alloc::string::String, + #[prost(message, optional, tag="2")] + pub value: ::core::option::Option, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct KeyValuePairList { + #[prost(message, repeated, tag="1")] + pub kv_pairs: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Expression { + #[prost(oneof="expression::Value", tags="1, 2, 3")] + pub value: ::core::option::Option, +} +/// Nested message and enum types in `Expression`. +pub mod expression { + #[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Value { + #[prost(string, tag="1")] + StringValue(::prost::alloc::string::String), + #[prost(int64, tag="2")] + Int64Value(i64), + #[prost(bool, tag="3")] + BoolValue(bool), + } +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ExpressionList { + #[prost(message, repeated, tag="1")] + pub expressions: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct StructuredAnnotation { + #[prost(string, tag="1")] + pub name: ::prost::alloc::string::String, + /// Optional. Location of the '@' symbol of this annotation in the source code. + #[prost(message, optional, tag="4")] + pub source_location: ::core::option::Option, + #[prost(oneof="structured_annotation::Body", tags="2, 3")] + pub body: ::core::option::Option, +} +/// Nested message and enum types in `StructuredAnnotation`. +pub mod structured_annotation { + #[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Body { + #[prost(message, tag="2")] + ExpressionList(super::ExpressionList), + #[prost(message, tag="3")] + KvPairList(super::KeyValuePairList), + } +} +/// Location of code relative to a given source file. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct SourceLocation { + /// Path to the source file (absolute or relative to the working directory). + #[prost(string, tag="1")] + pub file: ::prost::alloc::string::String, + /// Line and column numbers within the source file, 1-based. + #[prost(int32, tag="2")] + pub line: i32, + #[prost(int32, tag="3")] + pub column: i32, +} +/// For "safe" enums with no underlying representation and no member integer +/// values. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct P4EnumTypeSpec { + #[prost(message, repeated, tag="1")] + pub members: ::prost::alloc::vec::Vec, + #[prost(string, repeated, tag="2")] + pub annotations: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + /// Optional. If present, the location of `annotations\[i\]` is given by + /// `annotation_locations\[i\]`. + #[prost(message, repeated, tag="4")] + pub annotation_locations: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="3")] + pub structured_annotations: ::prost::alloc::vec::Vec, +} +/// Nested message and enum types in `P4EnumTypeSpec`. +pub mod p4_enum_type_spec { + #[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] + pub struct Member { + #[prost(string, tag="1")] + pub name: ::prost::alloc::string::String, + #[prost(string, repeated, tag="2")] + pub annotations: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + /// Optional. If present, the location of `annotations\[i\]` is given by + /// `annotation_locations\[i\]`. + #[prost(message, repeated, tag="4")] + pub annotation_locations: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="3")] + pub structured_annotations: ::prost::alloc::vec::Vec, + } +} +/// For serializable (or "unsafe") enums, which have an underlying type. Note +/// that as per the P4_16 specification, the underlying representation can only +/// be a bit type. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct P4SerializableEnumTypeSpec { + #[prost(message, optional, tag="1")] + pub underlying_type: ::core::option::Option, + #[prost(message, repeated, tag="2")] + pub members: ::prost::alloc::vec::Vec, + #[prost(string, repeated, tag="3")] + pub annotations: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + /// Optional. If present, the location of `annotations\[i\]` is given by + /// `annotation_locations\[i\]`. + #[prost(message, repeated, tag="5")] + pub annotation_locations: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="4")] + pub structured_annotations: ::prost::alloc::vec::Vec, +} +/// Nested message and enum types in `P4SerializableEnumTypeSpec`. +pub mod p4_serializable_enum_type_spec { + #[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] + pub struct Member { + #[prost(string, tag="1")] + pub name: ::prost::alloc::string::String, + #[prost(bytes="vec", tag="2")] + pub value: ::prost::alloc::vec::Vec, + #[prost(string, repeated, tag="3")] + pub annotations: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + /// Optional. If present, the location of `annotations\[i\]` is given by + /// `annotation_locations\[i\]`. + #[prost(message, repeated, tag="5")] + pub annotation_locations: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="4")] + pub structured_annotations: ::prost::alloc::vec::Vec, + } +} +/// Similar to an enum, but there is always one and only one instance per P4 +/// program. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct P4ErrorTypeSpec { + #[prost(string, repeated, tag="1")] + pub members: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct P4NewTypeTranslation { + /// the URI uniquely identifies the translation in order to enable the + /// P4Runtime agent to perform value-mapping appropriately when required. It is + /// recommended that the URI includes at least the P4 architecture name and the + /// type name. + #[prost(string, tag="1")] + pub uri: ::prost::alloc::string::String, + /// The object is either represented as an unsigned integer with a bitwidth of + /// `sdn_bitwidth`, or as a string. + #[prost(oneof="p4_new_type_translation::SdnType", tags="2, 3")] + pub sdn_type: ::core::option::Option, +} +/// Nested message and enum types in `P4NewTypeTranslation`. +pub mod p4_new_type_translation { + #[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] + pub struct SdnString { + } + /// The object is either represented as an unsigned integer with a bitwidth of + /// `sdn_bitwidth`, or as a string. + #[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum SdnType { + #[prost(int32, tag="2")] + SdnBitwidth(i32), + #[prost(message, tag="3")] + SdnString(SdnString), + } +} +/// New types introduced with the "type" keyword +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct P4NewTypeSpec { + /// for other annotations (not @p4runtime_translation) + #[prost(string, repeated, tag="3")] + pub annotations: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + /// Optional. If present, the location of `annotations\[i\]` is given by + /// `annotation_locations\[i\]`. + #[prost(message, repeated, tag="5")] + pub annotation_locations: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="4")] + pub structured_annotations: ::prost::alloc::vec::Vec, + #[prost(oneof="p4_new_type_spec::Representation", tags="1, 2")] + pub representation: ::core::option::Option, +} +/// Nested message and enum types in `P4NewTypeSpec`. +pub mod p4_new_type_spec { + #[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Representation { + /// if no @p4runtime_translation annotation present + #[prost(message, tag="1")] + OriginalType(super::P4DataTypeSpec), + /// if @p4runtime_translation annotation present + #[prost(message, tag="2")] + TranslatedType(super::P4NewTypeTranslation), + } +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct P4Info { + #[prost(message, optional, tag="1")] + pub pkg_info: ::core::option::Option, + #[prost(message, repeated, tag="2")] + pub tables: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="3")] + pub actions: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="4")] + pub action_profiles: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="5")] + pub counters: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="6")] + pub direct_counters: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="7")] + pub meters: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="8")] + pub direct_meters: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="9")] + pub controller_packet_metadata: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="10")] + pub value_sets: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="11")] + pub registers: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="12")] + pub digests: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="100")] + pub externs: ::prost::alloc::vec::Vec, + #[prost(message, optional, tag="200")] + pub type_info: ::core::option::Option, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Documentation { + /// A brief description of something, e.g. one sentence + #[prost(string, tag="1")] + pub brief: ::prost::alloc::string::String, + /// A more verbose description of something. Multiline is accepted. Markup + /// format (if any) is TBD. + #[prost(string, tag="2")] + pub description: ::prost::alloc::string::String, +} +/// Used to describe the required properties of the underlying platform. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PlatformProperties { + /// The minimum number of multicast entries (i.e. multicast groups) that the + /// platform is required to support. If 0, there are no requirements. + #[prost(int32, tag="1")] + pub multicast_group_table_size: i32, + /// The minimum number of replicas that the platform is required to support + /// across all groups. If 0, there are no requirements. + #[prost(int32, tag="2")] + pub multicast_group_table_total_replicas: i32, + /// The number of replicas that the platform is required to support per + /// group/entry. If 0, `multicast_group_table_total_replicas` should be used. + /// Must be no larger than `multicast_group_table_total_replicas`. + #[prost(int32, tag="3")] + pub multicast_group_table_max_replicas_per_entry: i32, +} +/// Top-level package documentation describing the forwarding pipeline config +/// Can be used to manage multiple P4 packages. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PkgInfo { + /// a definitive name for this configuration, e.g. switch.p4_v1.0 + #[prost(string, tag="1")] + pub name: ::prost::alloc::string::String, + /// configuration version, free-format string + #[prost(string, tag="2")] + pub version: ::prost::alloc::string::String, + /// brief and detailed descriptions + #[prost(message, optional, tag="3")] + pub doc: ::core::option::Option, + /// Miscellaneous metadata, free-form; a way to extend PkgInfo + #[prost(string, repeated, tag="4")] + pub annotations: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + /// Optional. If present, the location of `annotations\[i\]` is given by + /// `annotation_locations\[i\]`. + #[prost(message, repeated, tag="10")] + pub annotation_locations: ::prost::alloc::vec::Vec, + /// the target architecture, e.g. "psa" + #[prost(string, tag="5")] + pub arch: ::prost::alloc::string::String, + /// organization which produced the configuration, e.g. "p4.org" + #[prost(string, tag="6")] + pub organization: ::prost::alloc::string::String, + /// contact info for support,e.g. "tech-support@acme.org" + #[prost(string, tag="7")] + pub contact: ::prost::alloc::string::String, + /// url for more information, e.g. + /// " + #[prost(string, tag="8")] + pub url: ::prost::alloc::string::String, + /// Miscellaneous metadata, structured; a way to extend PkgInfo + #[prost(message, repeated, tag="9")] + pub structured_annotations: ::prost::alloc::vec::Vec, + /// If set, specifies the properties that the underlying platform should have. + /// If the platform does not conform to these properties, the server should + /// reject the P4Info when used with a SetForwardingPipelineConfigRequest. + #[prost(message, optional, tag="11")] + pub platform_properties: ::core::option::Option, +} +/// wrapping the enum in a message to avoid name collisions in C++, where "enum +/// values are siblings of their type, not children of it" +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct P4Ids { +} +/// Nested message and enum types in `P4Ids`. +pub mod p4_ids { + /// ids are allocated in such a way that it is possible based on an id to + /// deduce the resource type (e.g. table, action, counter, ...). The + /// most-significant byte of the 32-bit id encodes the resource type. The + /// purpose of this enum is to define which value is used as the + /// most-significant byte for each resource type. The P4 compiler must use + /// these values when allocating ids for P4 objects. Other users of P4Info can + /// refer to this enum to identify a resource type based on its id. + #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] + #[repr(i32)] + pub enum Prefix { + Unspecified = 0, + /// P4 language built-ins + Action = 1, + Table = 2, + ValueSet = 3, + ControllerHeader = 4, + /// PSA externs + PsaExternsStart = 16, + ActionProfile = 17, + Counter = 18, + DirectCounter = 19, + Meter = 20, + DirectMeter = 21, + Register = 22, + Digest = 23, + /// externs for other architectures (vendor extensions) + OtherExternsStart = 128, + /// max value for an unsigned 8-bit byte + /// + /// requires protoc >= 3.5.0 + /// reserved 0x100 to max; + Max = 255, + } + impl Prefix { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + Prefix::Unspecified => "UNSPECIFIED", + Prefix::Action => "ACTION", + Prefix::Table => "TABLE", + Prefix::ValueSet => "VALUE_SET", + Prefix::ControllerHeader => "CONTROLLER_HEADER", + Prefix::PsaExternsStart => "PSA_EXTERNS_START", + Prefix::ActionProfile => "ACTION_PROFILE", + Prefix::Counter => "COUNTER", + Prefix::DirectCounter => "DIRECT_COUNTER", + Prefix::Meter => "METER", + Prefix::DirectMeter => "DIRECT_METER", + Prefix::Register => "REGISTER", + Prefix::Digest => "DIGEST", + Prefix::OtherExternsStart => "OTHER_EXTERNS_START", + Prefix::Max => "MAX", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "UNSPECIFIED" => Some(Self::Unspecified), + "ACTION" => Some(Self::Action), + "TABLE" => Some(Self::Table), + "VALUE_SET" => Some(Self::ValueSet), + "CONTROLLER_HEADER" => Some(Self::ControllerHeader), + "PSA_EXTERNS_START" => Some(Self::PsaExternsStart), + "ACTION_PROFILE" => Some(Self::ActionProfile), + "COUNTER" => Some(Self::Counter), + "DIRECT_COUNTER" => Some(Self::DirectCounter), + "METER" => Some(Self::Meter), + "DIRECT_METER" => Some(Self::DirectMeter), + "REGISTER" => Some(Self::Register), + "DIGEST" => Some(Self::Digest), + "OTHER_EXTERNS_START" => Some(Self::OtherExternsStart), + "MAX" => Some(Self::Max), + _ => None, + } + } + } +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Preamble { + /// ids share the same number-space; e.g. table ids cannot overlap with counter + /// ids. Even though this is irrelevant to this proto definition, the ids are + /// allocated in such a way that it is possible based on an id to deduce the + /// resource type (e.g. table, action, counter, ...). This means that code + /// using these ids can detect if the wrong resource type is used + /// somewhere. This also means that ids of different types can be mixed + /// (e.g. direct resource list for a table) without ambiguity. Note that id 0 + /// is reserved and means "invalid id". + #[prost(uint32, tag="1")] + pub id: u32, + /// fully qualified name of the P4 object, e.g. c1.c2.ipv4_lpm + #[prost(string, tag="2")] + pub name: ::prost::alloc::string::String, + /// an alias (alternative name) for the P4 object, probably shorter than its + /// fully qualified name. The only constraint is for it to be unique with + /// respect to other P4 objects of the same type. By default, the compiler uses + /// the shortest suffix of the name that uniquely identifies the object. For + /// example if the P4 program contains two tables with names s.c1.t and s.c2.t, + /// the default aliases will respectively be c1.t and c2.t. In the future, the + /// P4 programmer may also be able to override the default alias for any P4 + /// object (TBD). + #[prost(string, tag="3")] + pub alias: ::prost::alloc::string::String, + #[prost(string, repeated, tag="4")] + pub annotations: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + /// Optional. If present, the location of `annotations\[i\]` is given by + /// `annotation_locations\[i\]`. + #[prost(message, repeated, tag="7")] + pub annotation_locations: ::prost::alloc::vec::Vec, + /// Documentation of the entity + #[prost(message, optional, tag="5")] + pub doc: ::core::option::Option, + #[prost(message, repeated, tag="6")] + pub structured_annotations: ::prost::alloc::vec::Vec, +} +/// used to group all extern instances of the same type in one message +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Extern { + /// the extern_type_id is unique for a given architecture and must be in the + /// range \[0x81, 0xfe\]. + #[prost(uint32, tag="1")] + pub extern_type_id: u32, + #[prost(string, tag="2")] + pub extern_type_name: ::prost::alloc::string::String, + #[prost(message, repeated, tag="3")] + pub instances: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ExternInstance { + #[prost(message, optional, tag="1")] + pub preamble: ::core::option::Option, + /// specific to the extern type, declared in a separate vendor-specific proto + /// file + #[prost(message, optional, tag="2")] + pub info: ::core::option::Option<::pbjson_types::Any>, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct MatchField { + #[prost(uint32, tag="1")] + pub id: u32, + #[prost(string, tag="2")] + pub name: ::prost::alloc::string::String, + #[prost(string, repeated, tag="3")] + pub annotations: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + /// Optional. If present, the location of `annotations\[i\]` is given by + /// `annotation_locations\[i\]`. + #[prost(message, repeated, tag="10")] + pub annotation_locations: ::prost::alloc::vec::Vec, + #[prost(int32, tag="4")] + pub bitwidth: i32, + /// Documentation of the match field + #[prost(message, optional, tag="6")] + pub doc: ::core::option::Option, + /// unset if not user-defined type + #[prost(message, optional, tag="8")] + pub type_name: ::core::option::Option, + #[prost(message, repeated, tag="9")] + pub structured_annotations: ::prost::alloc::vec::Vec, + #[prost(oneof="match_field::Match", tags="5, 7")] + pub r#match: ::core::option::Option, +} +/// Nested message and enum types in `MatchField`. +pub mod match_field { + #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] + #[repr(i32)] + pub enum MatchType { + Unspecified = 0, + Exact = 2, + Lpm = 3, + Ternary = 4, + Range = 5, + Optional = 6, + } + impl MatchType { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + MatchType::Unspecified => "UNSPECIFIED", + MatchType::Exact => "EXACT", + MatchType::Lpm => "LPM", + MatchType::Ternary => "TERNARY", + MatchType::Range => "RANGE", + MatchType::Optional => "OPTIONAL", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "UNSPECIFIED" => Some(Self::Unspecified), + "EXACT" => Some(Self::Exact), + "LPM" => Some(Self::Lpm), + "TERNARY" => Some(Self::Ternary), + "RANGE" => Some(Self::Range), + "OPTIONAL" => Some(Self::Optional), + _ => None, + } + } + } + #[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Match { + #[prost(enumeration="MatchType", tag="5")] + MatchType(i32), + /// used for architecture-specific match types which are not part of the core + /// P4 language or of the PSA architecture. + #[prost(string, tag="7")] + OtherMatchType(::prost::alloc::string::String), + } +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Table { + #[prost(message, optional, tag="1")] + pub preamble: ::core::option::Option, + #[prost(message, repeated, tag="2")] + pub match_fields: ::prost::alloc::vec::Vec, + /// even when the table is indirect (see implementation_id) below, this field + /// includes all possible actions for the table; by using ActionRef instead of + /// a repeated field of action ids, each action reference in a P4 table is able + /// to have its own annotations + #[prost(message, repeated, tag="3")] + pub action_refs: ::prost::alloc::vec::Vec, + /// 0 (default value) means that the table does not have a const default action + #[prost(uint32, tag="4")] + pub const_default_action_id: u32, + /// P4 id of the "implementation" for this table (e.g. action profile id); 0 + /// (default value) means that the table is a regular (direct) match table. As + /// of today, only action profiles are supported but other table + /// implementations may be added in the future + #[prost(uint32, tag="6")] + pub implementation_id: u32, + /// ids of the direct resources (if any) attached to this table; for now this + /// includes only direct counters and direct meters, but other resources may be + /// added in the future + #[prost(uint32, repeated, tag="7")] + pub direct_resource_ids: ::prost::alloc::vec::Vec, + /// max number of entries in table + #[prost(int64, tag="8")] + pub size: i64, + /// is idle timeout supported for this table? + #[prost(enumeration="table::IdleTimeoutBehavior", tag="9")] + pub idle_timeout_behavior: i32, + /// True if and only if the table's entries are immutable, + /// i.e. defined using the 'const entries' table property in the P4 + /// source code, and thus entries cannot be deleted, modified, or + /// inserted at run time. + #[prost(bool, tag="10")] + pub is_const_table: bool, + /// True if and only if the table has initial entries defined using + /// the 'entries' table property in the P4 source code, either with + /// or without the 'const' qualifier on 'entries', and there is at + /// least one entry in that list. This field is false if the list of + /// entries is empty in the P4 source code. + /// Added in 1.4.0. + #[prost(bool, tag="11")] + pub has_initial_entries: bool, + /// architecture-specific table properties which are not part of the core P4 + /// language or of the PSA architecture. + #[prost(message, optional, tag="100")] + pub other_properties: ::core::option::Option<::pbjson_types::Any>, +} +/// Nested message and enum types in `Table`. +pub mod table { + /// this enum can be extended in the future with other behaviors, such as + /// "HARD_EVICTION" + #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] + #[repr(i32)] + pub enum IdleTimeoutBehavior { + NoTimeout = 0, + NotifyControl = 1, + } + impl IdleTimeoutBehavior { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + IdleTimeoutBehavior::NoTimeout => "NO_TIMEOUT", + IdleTimeoutBehavior::NotifyControl => "NOTIFY_CONTROL", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "NO_TIMEOUT" => Some(Self::NoTimeout), + "NOTIFY_CONTROL" => Some(Self::NotifyControl), + _ => None, + } + } + } +} +/// used to list all possible actions in a Table +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ActionRef { + #[prost(uint32, tag="1")] + pub id: u32, + #[prost(enumeration="action_ref::Scope", tag="3")] + pub scope: i32, + #[prost(string, repeated, tag="2")] + pub annotations: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + /// Optional. If present, the location of `annotations\[i\]` is given by + /// `annotation_locations\[i\]`. + #[prost(message, repeated, tag="5")] + pub annotation_locations: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="4")] + pub structured_annotations: ::prost::alloc::vec::Vec, +} +/// Nested message and enum types in `ActionRef`. +pub mod action_ref { + #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] + #[repr(i32)] + pub enum Scope { + TableAndDefault = 0, + TableOnly = 1, + DefaultOnly = 2, + } + impl Scope { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + Scope::TableAndDefault => "TABLE_AND_DEFAULT", + Scope::TableOnly => "TABLE_ONLY", + Scope::DefaultOnly => "DEFAULT_ONLY", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "TABLE_AND_DEFAULT" => Some(Self::TableAndDefault), + "TABLE_ONLY" => Some(Self::TableOnly), + "DEFAULT_ONLY" => Some(Self::DefaultOnly), + _ => None, + } + } + } +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Action { + #[prost(message, optional, tag="1")] + pub preamble: ::core::option::Option, + #[prost(message, repeated, tag="2")] + pub params: ::prost::alloc::vec::Vec, +} +/// Nested message and enum types in `Action`. +pub mod action { + #[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] + pub struct Param { + #[prost(uint32, tag="1")] + pub id: u32, + #[prost(string, tag="2")] + pub name: ::prost::alloc::string::String, + #[prost(string, repeated, tag="3")] + pub annotations: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + /// Optional. If present, the location of `annotations\[i\]` is given by + /// `annotation_locations\[i\]`. + #[prost(message, repeated, tag="8")] + pub annotation_locations: ::prost::alloc::vec::Vec, + #[prost(int32, tag="4")] + pub bitwidth: i32, + /// Documentation of the Param + #[prost(message, optional, tag="5")] + pub doc: ::core::option::Option, + /// unset if not user-defined type + #[prost(message, optional, tag="6")] + pub type_name: ::core::option::Option, + #[prost(message, repeated, tag="7")] + pub structured_annotations: ::prost::alloc::vec::Vec, + } +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ActionProfile { + #[prost(message, optional, tag="1")] + pub preamble: ::core::option::Option, + /// the ids of the tables sharing this action profile + #[prost(uint32, repeated, tag="2")] + pub table_ids: ::prost::alloc::vec::Vec, + /// true iff the action profile used dynamic selection + #[prost(bool, tag="3")] + pub with_selector: bool, + /// max number of member entries across all groups if the action profile does + /// not have a selector. Otherwise, semantics as specified by + /// `selector_size_semantics` below. + #[prost(int64, tag="4")] + pub size: i64, + /// 0 if the action profile does not have a selector. Otherwise, semantics as + /// specified by `selector_size_semantics` below. + #[prost(int32, tag="5")] + pub max_group_size: i32, + /// specifies the semantics of `size` and `max_group_size` above + #[prost(oneof="action_profile::SelectorSizeSemantics", tags="6, 7")] + pub selector_size_semantics: ::core::option::Option, +} +/// Nested message and enum types in `ActionProfile`. +pub mod action_profile { + /// indicates that `size` and `max_group_size` represent the maximum sum of + /// weights that can be present across all selector groups and within a + /// single selector group respectively. + #[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] + pub struct SumOfWeights { + } + /// indicates that `size` and `max_group_size` represent the maximum number + /// of members that can be present across all selector groups and within a + /// single selector group respectively. + #[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] + pub struct SumOfMembers { + /// the maximum weight of each individual member in a group. + #[prost(int32, optional, tag="1")] + pub max_member_weight: ::core::option::Option, + } + /// specifies the semantics of `size` and `max_group_size` above + #[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum SelectorSizeSemantics { + /// group size is the sum of the group's weights. + #[prost(message, tag="6")] + SumOfWeights(SumOfWeights), + /// group size is the sum of the group's members. + #[prost(message, tag="7")] + SumOfMembers(SumOfMembers), + } +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct CounterSpec { + #[prost(enumeration="counter_spec::Unit", tag="1")] + pub unit: i32, +} +/// Nested message and enum types in `CounterSpec`. +pub mod counter_spec { + /// Corresponds to 'type' constructor parameter for Counter / DirectCounter in + /// PSA + #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] + #[repr(i32)] + pub enum Unit { + Unspecified = 0, + Bytes = 1, + Packets = 2, + Both = 3, + } + impl Unit { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + Unit::Unspecified => "UNSPECIFIED", + Unit::Bytes => "BYTES", + Unit::Packets => "PACKETS", + Unit::Both => "BOTH", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "UNSPECIFIED" => Some(Self::Unspecified), + "BYTES" => Some(Self::Bytes), + "PACKETS" => Some(Self::Packets), + "BOTH" => Some(Self::Both), + _ => None, + } + } + } +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Counter { + #[prost(message, optional, tag="1")] + pub preamble: ::core::option::Option, + #[prost(message, optional, tag="2")] + pub spec: ::core::option::Option, + /// number of entries in the counter array + #[prost(int64, tag="3")] + pub size: i64, + /// unset if index is not user-defined type + #[prost(message, optional, tag="4")] + pub index_type_name: ::core::option::Option, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct DirectCounter { + #[prost(message, optional, tag="1")] + pub preamble: ::core::option::Option, + #[prost(message, optional, tag="2")] + pub spec: ::core::option::Option, + /// the id of the table to which the counter is attached + #[prost(uint32, tag="3")] + pub direct_table_id: u32, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct MeterSpec { + #[prost(enumeration="meter_spec::Unit", tag="1")] + pub unit: i32, +} +/// Nested message and enum types in `MeterSpec`. +pub mod meter_spec { + /// Corresponds to 'type' constructor parameter for Meter / DirectMeter in PSA + #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] + #[repr(i32)] + pub enum Unit { + Unspecified = 0, + Bytes = 1, + Packets = 2, + } + impl Unit { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + Unit::Unspecified => "UNSPECIFIED", + Unit::Bytes => "BYTES", + Unit::Packets => "PACKETS", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "UNSPECIFIED" => Some(Self::Unspecified), + "BYTES" => Some(Self::Bytes), + "PACKETS" => Some(Self::Packets), + _ => None, + } + } + } +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Meter { + #[prost(message, optional, tag="1")] + pub preamble: ::core::option::Option, + #[prost(message, optional, tag="2")] + pub spec: ::core::option::Option, + /// number of entries in the meter array + #[prost(int64, tag="3")] + pub size: i64, + /// unset if index is not user-defined type + #[prost(message, optional, tag="4")] + pub index_type_name: ::core::option::Option, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct DirectMeter { + #[prost(message, optional, tag="1")] + pub preamble: ::core::option::Option, + #[prost(message, optional, tag="2")] + pub spec: ::core::option::Option, + /// the id of the table to which the meter is attached + #[prost(uint32, tag="3")] + pub direct_table_id: u32, +} +/// Any metadata associated with controller Packet-IO (Packet-In or Packet-Out) +/// is modeled as P4 headers carrying special annotations +/// @controller_header("packet_out") and @controller_header("packet_in") +/// respectively. There can be at most one header each with these annotations. +/// This message captures the info contained within these special headers, +/// and used in p4runtime.proto to supply the metadata. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ControllerPacketMetadata { + /// preamble.name and preamble.id will specify header type ("packet_out" or + /// "packet_in" for now). + #[prost(message, optional, tag="1")] + pub preamble: ::core::option::Option, + /// Ordered based on header layout. + /// This is a constraint on the generator of this P4Info. + #[prost(message, repeated, tag="2")] + pub metadata: ::prost::alloc::vec::Vec, +} +/// Nested message and enum types in `ControllerPacketMetadata`. +pub mod controller_packet_metadata { + #[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] + pub struct Metadata { + #[prost(uint32, tag="1")] + pub id: u32, + /// This is the name of the header field (not fully-qualified), similar + /// to e.g. Action.Param.name. + #[prost(string, tag="2")] + pub name: ::prost::alloc::string::String, + #[prost(string, repeated, tag="3")] + pub annotations: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + /// Optional. If present, the location of `annotations\[i\]` is given by + /// `annotation_locations\[i\]`. + #[prost(message, repeated, tag="7")] + pub annotation_locations: ::prost::alloc::vec::Vec, + #[prost(int32, tag="4")] + pub bitwidth: i32, + /// unset if not user-defined type + #[prost(message, optional, tag="5")] + pub type_name: ::core::option::Option, + #[prost(message, repeated, tag="6")] + pub structured_annotations: ::prost::alloc::vec::Vec, + } +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ValueSet { + #[prost(message, optional, tag="1")] + pub preamble: ::core::option::Option, + #[prost(message, repeated, tag="2")] + pub r#match: ::prost::alloc::vec::Vec, + /// number of entries in the value_set, as per the P4 constructor call. + #[prost(int32, tag="3")] + pub size: i32, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Register { + #[prost(message, optional, tag="1")] + pub preamble: ::core::option::Option, + #[prost(message, optional, tag="2")] + pub type_spec: ::core::option::Option, + #[prost(int32, tag="3")] + pub size: i32, + /// unset if index is not user-defined type + #[prost(message, optional, tag="4")] + pub index_type_name: ::core::option::Option, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Digest { + #[prost(message, optional, tag="1")] + pub preamble: ::core::option::Option, + #[prost(message, optional, tag="2")] + pub type_spec: ::core::option::Option, +} +// @@protoc_insertion_point(module) diff --git a/rust/src/p4.v1.rs b/rust/src/p4.v1.rs new file mode 100644 index 00000000..4e8f95f7 --- /dev/null +++ b/rust/src/p4.v1.rs @@ -0,0 +1,1351 @@ +// @generated +// This file is @generated by prost-build. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct P4Data { + #[prost(oneof="p4_data::Data", tags="1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12")] + pub data: ::core::option::Option, +} +/// Nested message and enum types in `P4Data`. +pub mod p4_data { + #[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Data { + /// for bit, int + #[prost(bytes, tag="1")] + Bitstring(::prost::alloc::vec::Vec), + /// for varbit + #[prost(message, tag="2")] + Varbit(super::P4Varbit), + #[prost(bool, tag="3")] + Bool(bool), + #[prost(message, tag="4")] + Tuple(super::P4StructLike), + #[prost(message, tag="5")] + Struct(super::P4StructLike), + #[prost(message, tag="6")] + Header(super::P4Header), + #[prost(message, tag="7")] + HeaderUnion(super::P4HeaderUnion), + #[prost(message, tag="8")] + HeaderStack(super::P4HeaderStack), + #[prost(message, tag="9")] + HeaderUnionStack(super::P4HeaderUnionStack), + /// safe (non-serializable) enums only + #[prost(string, tag="10")] + Enum(::prost::alloc::string::String), + #[prost(string, tag="11")] + Error(::prost::alloc::string::String), + /// serializable enums only + #[prost(bytes, tag="12")] + EnumValue(::prost::alloc::vec::Vec), + } +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct P4Varbit { + #[prost(bytes="vec", tag="1")] + pub bitstring: ::prost::alloc::vec::Vec, + /// dynamic bitwidth of the field + #[prost(int32, tag="2")] + pub bitwidth: i32, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct P4StructLike { + #[prost(message, repeated, tag="1")] + pub members: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct P4Header { + /// If the header is invalid (is_valid is "false"), then the bitstrings + /// repeated field must be empty. + #[prost(bool, tag="1")] + pub is_valid: bool, + #[prost(bytes="vec", repeated, tag="2")] + pub bitstrings: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct P4HeaderUnion { + /// An empty string indicates that none of the union members are valid and + /// valid_header must therefore be unset. + #[prost(string, tag="1")] + pub valid_header_name: ::prost::alloc::string::String, + #[prost(message, optional, tag="2")] + pub valid_header: ::core::option::Option, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct P4HeaderStack { + /// The length of this repeated field must always be equal to the compile-time + /// size of the header stack, which is specified in P4Info. + #[prost(message, repeated, tag="1")] + pub entries: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct P4HeaderUnionStack { + /// The length of this repeated field must always be equal to the compile-time + /// size of the header union stack, which is specified in P4Info. + #[prost(message, repeated, tag="1")] + pub entries: ::prost::alloc::vec::Vec, +} +/// ------------------------------------------------------------------------------ +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct WriteRequest { + #[prost(uint64, tag="1")] + pub device_id: u64, + #[deprecated] + #[prost(uint64, tag="2")] + pub role_id: u64, + #[prost(string, tag="6")] + pub role: ::prost::alloc::string::String, + #[prost(message, optional, tag="3")] + pub election_id: ::core::option::Option, + /// The write batch, comprising a list of Update operations. The P4Runtime + /// server may arbitrarily reorder messages within a batch to maximize + /// performance. + #[prost(message, repeated, tag="4")] + pub updates: ::prost::alloc::vec::Vec, + #[prost(enumeration="write_request::Atomicity", tag="5")] + pub atomicity: i32, +} +/// Nested message and enum types in `WriteRequest`. +pub mod write_request { + #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] + #[repr(i32)] + pub enum Atomicity { + /// Required. This is the default behavior. The batch is processed in a + /// non-atomic manner from a data plane point of view. Each operation within + /// the batch must be attempted even if one or more encounter errors. + /// Every data plane packet is guaranteed to be processed according to + /// table contents as they are between two individual operations of the + /// batch, but there could be several packets processed that see each of + /// these intermediate stages. + ContinueOnError = 0, + /// Optional. Operations within the batch are committed to data plane until + /// an error is encountered. At this point, the operations must be rolled + /// back such that both software and data plane state is consistent with the + /// state before the batch was attempted. The resulting behavior is + /// all-or-none, except the batch is not atomic from a data plane point of + /// view. Every data plane packet is guaranteed to be processed according to + /// table contents as they are between two individual operations of the + /// batch, but there could be several packets processed that see each of + /// these intermediate stages. + RollbackOnError = 1, + /// Optional. Every data plane packet is guaranteed to be processed according + /// to table contents before the batch began, or after the batch completed + /// and the operations were programmed to the hardware. + /// The batch is therefore treated as a transaction. + DataplaneAtomic = 2, + } + impl Atomicity { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + Atomicity::ContinueOnError => "CONTINUE_ON_ERROR", + Atomicity::RollbackOnError => "ROLLBACK_ON_ERROR", + Atomicity::DataplaneAtomic => "DATAPLANE_ATOMIC", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "CONTINUE_ON_ERROR" => Some(Self::ContinueOnError), + "ROLLBACK_ON_ERROR" => Some(Self::RollbackOnError), + "DATAPLANE_ATOMIC" => Some(Self::DataplaneAtomic), + _ => None, + } + } + } +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct WriteResponse { +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ReadRequest { + #[prost(uint64, tag="1")] + pub device_id: u64, + /// When specified, only return table entries for the given role. + #[prost(string, tag="3")] + pub role: ::prost::alloc::string::String, + #[prost(message, repeated, tag="2")] + pub entities: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ReadResponse { + #[prost(message, repeated, tag="1")] + pub entities: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Update { + #[prost(enumeration="update::Type", tag="1")] + pub r#type: i32, + #[prost(message, optional, tag="2")] + pub entity: ::core::option::Option, +} +/// Nested message and enum types in `Update`. +pub mod update { + #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] + #[repr(i32)] + pub enum Type { + Unspecified = 0, + Insert = 1, + Modify = 2, + Delete = 3, + } + impl Type { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + Type::Unspecified => "UNSPECIFIED", + Type::Insert => "INSERT", + Type::Modify => "MODIFY", + Type::Delete => "DELETE", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "UNSPECIFIED" => Some(Self::Unspecified), + "INSERT" => Some(Self::Insert), + "MODIFY" => Some(Self::Modify), + "DELETE" => Some(Self::Delete), + _ => None, + } + } + } +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Entity { + #[prost(oneof="entity::Entity", tags="1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12")] + pub entity: ::core::option::Option, +} +/// Nested message and enum types in `Entity`. +pub mod entity { + #[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Entity { + #[prost(message, tag="1")] + ExternEntry(super::ExternEntry), + #[prost(message, tag="2")] + TableEntry(super::TableEntry), + #[prost(message, tag="3")] + ActionProfileMember(super::ActionProfileMember), + #[prost(message, tag="4")] + ActionProfileGroup(super::ActionProfileGroup), + #[prost(message, tag="5")] + MeterEntry(super::MeterEntry), + #[prost(message, tag="6")] + DirectMeterEntry(super::DirectMeterEntry), + #[prost(message, tag="7")] + CounterEntry(super::CounterEntry), + #[prost(message, tag="8")] + DirectCounterEntry(super::DirectCounterEntry), + #[prost(message, tag="9")] + PacketReplicationEngineEntry(super::PacketReplicationEngineEntry), + #[prost(message, tag="10")] + ValueSetEntry(super::ValueSetEntry), + #[prost(message, tag="11")] + RegisterEntry(super::RegisterEntry), + #[prost(message, tag="12")] + DigestEntry(super::DigestEntry), + } +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ExternEntry { + /// the extern_type_id is unique for a given architecture and must be in the + /// range \[0x81, 0xfe\]. + #[prost(uint32, tag="1")] + pub extern_type_id: u32, + /// id of the instance + #[prost(uint32, tag="2")] + pub extern_id: u32, + #[prost(message, optional, tag="3")] + pub entry: ::core::option::Option<::pbjson_types::Any>, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct TableEntry { + #[prost(uint32, tag="1")] + pub table_id: u32, + #[prost(message, repeated, tag="2")] + pub r#match: ::prost::alloc::vec::Vec, + #[prost(message, optional, tag="3")] + pub action: ::core::option::Option, + /// Should only be set if the match implies a TCAM lookup, i.e. at least one of + /// the match fields is Optional, Ternary or Range. A higher number indicates + /// higher priority. Only a highest priority entry that matches the packet + /// must be selected. Multiple entries in the same table with the same + /// priority value are permitted. See Section "TableEntry" in the + /// specification for details of the behavior. + #[prost(int32, tag="4")] + pub priority: i32, + /// Metadata (cookie) opaque to the target. There is no requirement of where + /// this is stored, as long as it is returned with the rest of the entry in + /// a Read RPC. This is deprecated in favor of the more flexible metadata + /// field. + #[deprecated] + #[prost(uint64, tag="5")] + pub controller_metadata: u64, + /// meter_config, counter_data and meter_counter_data are convenience fields + /// that enable the controller to configure the direct resources associated + /// with the table at the same time as a match-action entry is inserted or + /// modified. + /// Table write: + /// - If the table does not contain a direct resource, then setting the + /// corresponding direct resource field in any table write operation will + /// return an error. + /// - When inserting a new table entry, leaving these fields unset means that + /// the direct resources of this table (if any) will assume default values. + /// For counters, the default value is 0, and for meters, the default value + /// is always green. + /// - When updating a table entry, leaving meter_config unset will reset the + /// meter (if any) to its default configuration, while leaving counter_data + /// or meter_counter_data unset means that the counter (if any) will not be + /// updated. + /// Table read: + /// - If the table does not contain a direct resource, then the corresponding + /// field will not be set in the read table entry. + /// - If meter_config is unset in the request, or if the meter has a default + /// configuration, meter_config will not be set in the response. + /// - If counter_data or meter_counter_data is unset in the request, it will + /// be unset in the response as well. + #[prost(message, optional, tag="6")] + pub meter_config: ::core::option::Option, + #[prost(message, optional, tag="7")] + pub counter_data: ::core::option::Option, + /// Per color counters for tables with a direct meter. + #[prost(message, optional, tag="12")] + pub meter_counter_data: ::core::option::Option, + /// Set to true if the table entry is being used to update the non-const + /// default action of the table. If true, the "match" field must be empty and + /// the "action" field must be populated with a valid direct action. + #[prost(bool, tag="8")] + pub is_default_action: bool, + /// The TTL for the entry, in nanoseconds. A value of 0 means that the table + /// entry never "expires". + #[prost(int64, tag="9")] + pub idle_timeout_ns: i64, + /// Table write: this field should be left unset. + /// Table read: if the table supports idle timeout and time_since_last_hit is + /// set in the request, this field will be set in the response. + #[prost(message, optional, tag="10")] + pub time_since_last_hit: ::core::option::Option, + /// Arbitrary metadata from the controller that is opaque to the target. + #[prost(bytes="vec", tag="11")] + pub metadata: ::prost::alloc::vec::Vec, + /// True if and only if the entry cannot be deleted or modified, + /// i.e. any of the following: + /// + Any entry read from a table declared with `const entries` + /// + The default entry read from a table declared with `const + /// default_action` + /// + Any entry declared with `entries` without the `const` qualifier + /// before `entries`, where the individual entry has the `const` + /// qualifier on it in the P4 source code. + /// Note: Older P4Runtime API servers before the `is_const` field was + /// added to this message will not return a value for `is_const` in + /// the first two cases above, but newer P4Runtime API servers will. + /// Added in 1.4.0. + #[prost(bool, tag="13")] + pub is_const: bool, +} +/// Nested message and enum types in `TableEntry`. +pub mod table_entry { + #[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] + pub struct IdleTimeout { + /// Time elapsed - in nanoseconds - since the table entry was last "hit" as + /// part of a data plane table lookup. + #[prost(int64, tag="1")] + pub elapsed_ns: i64, + } +} +/// field_match_type ::= exact | ternary | lpm | range | optional +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct FieldMatch { + #[prost(uint32, tag="1")] + pub field_id: u32, + #[prost(oneof="field_match::FieldMatchType", tags="2, 3, 4, 6, 7, 100")] + pub field_match_type: ::core::option::Option, +} +/// Nested message and enum types in `FieldMatch`. +pub mod field_match { + /// Matches can be performed on arbitrarily-large inputs; the protobuf type + /// 'bytes' is used to model arbitrarily-large values. + #[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] + pub struct Exact { + #[prost(bytes="vec", tag="1")] + pub value: ::prost::alloc::vec::Vec, + } + #[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] + pub struct Ternary { + #[prost(bytes="vec", tag="1")] + pub value: ::prost::alloc::vec::Vec, + #[prost(bytes="vec", tag="2")] + pub mask: ::prost::alloc::vec::Vec, + } + #[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] + pub struct Lpm { + #[prost(bytes="vec", tag="1")] + pub value: ::prost::alloc::vec::Vec, + /// in bits + #[prost(int32, tag="2")] + pub prefix_len: i32, + } + /// A Range is logically a set that contains all values numerically between + /// 'low' and 'high' inclusively. + #[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] + pub struct Range { + #[prost(bytes="vec", tag="1")] + pub low: ::prost::alloc::vec::Vec, + #[prost(bytes="vec", tag="2")] + pub high: ::prost::alloc::vec::Vec, + } + /// If the Optional match should be a wildcard, the FieldMatch must be omitted. + /// Otherwise, this behaves like an exact match. + #[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] + pub struct Optional { + #[prost(bytes="vec", tag="1")] + pub value: ::prost::alloc::vec::Vec, + } + #[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum FieldMatchType { + #[prost(message, tag="2")] + Exact(Exact), + #[prost(message, tag="3")] + Ternary(Ternary), + #[prost(message, tag="4")] + Lpm(Lpm), + #[prost(message, tag="6")] + Range(Range), + #[prost(message, tag="7")] + Optional(Optional), + /// Architecture-specific match value; it corresponds to the other_match_type + /// in the P4Info MatchField message. + #[prost(message, tag="100")] + Other(::pbjson_types::Any), + } +} +/// table_actions ::= action_specification | action_profile_specification +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct TableAction { + #[prost(oneof="table_action::Type", tags="1, 2, 3, 4")] + pub r#type: ::core::option::Option, +} +/// Nested message and enum types in `TableAction`. +pub mod table_action { + #[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Type { + #[prost(message, tag="1")] + Action(super::Action), + #[prost(uint32, tag="2")] + ActionProfileMemberId(u32), + #[prost(uint32, tag="3")] + ActionProfileGroupId(u32), + #[prost(message, tag="4")] + ActionProfileActionSet(super::ActionProfileActionSet), + } +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Action { + #[prost(uint32, tag="1")] + pub action_id: u32, + #[prost(message, repeated, tag="4")] + pub params: ::prost::alloc::vec::Vec, +} +/// Nested message and enum types in `Action`. +pub mod action { + #[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] + pub struct Param { + #[prost(uint32, tag="2")] + pub param_id: u32, + #[prost(bytes="vec", tag="3")] + pub value: ::prost::alloc::vec::Vec, + } +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ActionProfileActionSet { + #[prost(message, repeated, tag="1")] + pub action_profile_actions: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ActionProfileAction { + #[prost(message, optional, tag="1")] + pub action: ::core::option::Option, + #[prost(int32, tag="2")] + pub weight: i32, + #[prost(oneof="action_profile_action::WatchKind", tags="3, 4")] + pub watch_kind: ::core::option::Option, +} +/// Nested message and enum types in `ActionProfileAction`. +pub mod action_profile_action { + #[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum WatchKind { + /// Using int32 as ports is deprecated, use watch_port instead. + #[prost(int32, tag="3")] + Watch(i32), + #[prost(bytes, tag="4")] + WatchPort(::prost::alloc::vec::Vec), + } +} +/// ------------------------------------------------------------------------------ +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ActionProfileMember { + #[prost(uint32, tag="1")] + pub action_profile_id: u32, + #[prost(uint32, tag="2")] + pub member_id: u32, + #[prost(message, optional, tag="3")] + pub action: ::core::option::Option, +} +/// ------------------------------------------------------------------------------ +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ActionProfileGroup { + #[prost(uint32, tag="1")] + pub action_profile_id: u32, + #[prost(uint32, tag="2")] + pub group_id: u32, + #[prost(message, repeated, tag="3")] + pub members: ::prost::alloc::vec::Vec, + /// Max number of weighted member entries in this group. It cannot be modified + /// after a group has been created. It must not exceed the static + /// max_group_size included in P4Info. If the max size is not known at group + /// creation-time, the client may leave this field unset (default value 0), in + /// which case the static max_group_size value will be used and the group will + /// be able to include up to max_group_size weighted member entries. + #[prost(int32, tag="4")] + pub max_size: i32, +} +/// Nested message and enum types in `ActionProfileGroup`. +pub mod action_profile_group { + #[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] + pub struct Member { + #[prost(uint32, tag="1")] + pub member_id: u32, + #[prost(int32, tag="2")] + pub weight: i32, + #[prost(oneof="member::WatchKind", tags="3, 4")] + pub watch_kind: ::core::option::Option, + } + /// Nested message and enum types in `Member`. + pub mod member { + #[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum WatchKind { + /// Using int32 as ports is deprecated, use watch_port instead. + #[prost(int32, tag="3")] + Watch(i32), + #[prost(bytes, tag="4")] + WatchPort(::prost::alloc::vec::Vec), + } + } +} +/// An index as a protobuf message. In proto3, fields cannot be optional and +/// there is no difference between an unset integer field and an integer field +/// set to 0. This is inconvenient for reading from P4 array-like structures, +/// such as indirect counters and meters. We need a way to do a wildcard read on +/// these but we cannot use a default zero index value to do so, as zero is a +/// valid index (first entry in the array). We therefore wrap the index in a +/// message. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Index { + #[prost(int64, tag="1")] + pub index: i64, +} +/// ------------------------------------------------------------------------------ +/// For WriteRequest, Update.Type must be MODIFY. +/// For ReadRequest, the scope is defined as follows: +/// - All meter cells for all meters if meter_id = 0 (default). +/// - All meter cells for given meter_id if index is unset (default). +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct MeterEntry { + #[prost(uint32, tag="1")] + pub meter_id: u32, + #[prost(message, optional, tag="2")] + pub index: ::core::option::Option, + #[prost(message, optional, tag="3")] + pub config: ::core::option::Option, + #[prost(message, optional, tag="4")] + pub counter_data: ::core::option::Option, +} +/// ------------------------------------------------------------------------------ +/// For WriteRequest, Update.Type must be MODIFY. INSERT and DELETE on direct +/// meters is not allowed and will return an error. The insertion/deletion +/// should happen as part of INSERT/DELETE on the associated table-entry. +/// For ReadRequest, the scope is defined as follows: +/// - All meter cells for all tables if table_entry.table_id = 0. +/// - All meter cells of a table if table_entry.table_id is present and +/// table_entry.match is empty. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct DirectMeterEntry { + /// The associated table entry. This field is required. + /// table_entry.action is ignored. Other fields specify the match. + #[prost(message, optional, tag="1")] + pub table_entry: ::core::option::Option, + #[prost(message, optional, tag="2")] + pub config: ::core::option::Option, + #[prost(message, optional, tag="3")] + pub counter_data: ::core::option::Option, +} +/// Modeled as RFC 2698: A Two Rate Three Color Marker (trTCM) +/// The trTCM meters a packet stream and marks its packets based on two rates, +/// Peak Information Rate (PIR) and Committed Information Rate (CIR), and their +/// associated burst sizes to be either green, yellow, or red. A packet is +/// marked red if it exceeds the PIR. Otherwise it is marked either yellow or +/// green depending on whether it exceeds or doesn't exceed the CIR. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct MeterConfig { + /// Committed information rate (units per sec) + #[prost(int64, tag="1")] + pub cir: i64, + /// Committed burst size + #[prost(int64, tag="2")] + pub cburst: i64, + /// Peak information rate (units per sec) + #[prost(int64, tag="3")] + pub pir: i64, + /// Peak burst size + #[prost(int64, tag="4")] + pub pburst: i64, +} +/// ------------------------------------------------------------------------------ +/// For WriteRequest, Update.Type must be MODIFY. +/// For ReadRequest, the scope is defined as follows: +/// - All counter cells for all counters if counter_id = 0 (default). +/// - All counter cells for given counter_id if index is unset (default). +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct CounterEntry { + #[prost(uint32, tag="1")] + pub counter_id: u32, + #[prost(message, optional, tag="2")] + pub index: ::core::option::Option, + #[prost(message, optional, tag="3")] + pub data: ::core::option::Option, +} +/// ------------------------------------------------------------------------------ +/// For WriteRequest, Update.Type must be MODIFY. INSERT and DELETE on direct +/// counters is not allowed and will return an error. The insertion/deletion +/// should happen as part of INSERT/DELETE on the associated table-entry. +/// For ReadRequest, the scope is defined as follows: +/// - All counter cells for all tables if table_entry.table_id = 0. +/// - All counter cells of a table if table_entry.table_id is present and +/// table_entry.match is empty. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct DirectCounterEntry { + /// The associated table entry. This field is required. + /// table_entry.action is ignored. Other fields specify the match. + #[prost(message, optional, tag="1")] + pub table_entry: ::core::option::Option, + #[prost(message, optional, tag="2")] + pub data: ::core::option::Option, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct CounterData { + #[prost(int64, tag="1")] + pub byte_count: i64, + #[prost(int64, tag="2")] + pub packet_count: i64, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct MeterCounterData { + #[prost(message, optional, tag="1")] + pub green: ::core::option::Option, + #[prost(message, optional, tag="2")] + pub yellow: ::core::option::Option, + #[prost(message, optional, tag="3")] + pub red: ::core::option::Option, +} +/// ------------------------------------------------------------------------------ +/// Only one instance of a Packet Replication Engine (PRE) is expected in the +/// P4 pipeline. Hence, no instance id is needed to access the PRE. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PacketReplicationEngineEntry { + #[prost(oneof="packet_replication_engine_entry::Type", tags="1, 2")] + pub r#type: ::core::option::Option, +} +/// Nested message and enum types in `PacketReplicationEngineEntry`. +pub mod packet_replication_engine_entry { + #[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Type { + #[prost(message, tag="1")] + MulticastGroupEntry(super::MulticastGroupEntry), + #[prost(message, tag="2")] + CloneSessionEntry(super::CloneSessionEntry), + } +} +/// Used for replicas created for cloning and multicasting actions. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Replica { + #[prost(uint32, tag="2")] + pub instance: u32, + #[prost(oneof="replica::PortKind", tags="1, 3")] + pub port_kind: ::core::option::Option, +} +/// Nested message and enum types in `Replica`. +pub mod replica { + #[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum PortKind { + /// Using uint32 as ports is deprecated, use port field instead. + #[prost(uint32, tag="1")] + EgressPort(u32), + #[prost(bytes, tag="3")] + Port(::prost::alloc::vec::Vec), + } +} +/// The (port, instance) pair must be unique for each replica in a given +/// multicast group entry. A packet may be multicast by setting the +/// multicast_group field of PSA ingress output metadata to multicast_group_id +/// of a programmed multicast group entry. The port and instance fields of each +/// replica's egress input metadata will be set to the respective values +/// programmed in the multicast group entry. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct MulticastGroupEntry { + #[prost(uint32, tag="1")] + pub multicast_group_id: u32, + #[prost(message, repeated, tag="2")] + pub replicas: ::prost::alloc::vec::Vec, + /// Arbitrary metadata from the controller that is opaque to the target. + /// Added in 1.4.0. + #[prost(bytes="vec", tag="3")] + pub metadata: ::prost::alloc::vec::Vec, +} +/// A packet may be cloned by setting the clone_session_id field of PSA +/// ingress/egress output metadata to session_id of a programmed clone session +/// entry. Multiple clones may be created via a single clone session entry by +/// using the replicas message. The clones may be distinguished in the egress +/// using the instance field. The class_of_service field of the clone's egress +/// input metadata will be set to the respective value programmed in the clone +/// session entry. Note that in case of multiple clones, all clones, defined +/// for a clone session, will get the same class of service. The +/// packet_length_bytes field must be set to a non-zero value if the clone +/// packet(s) should be truncated to the given value (in bytes). The packet +/// length is also common to all clones in the clone session. If the +/// packet_length_bytes field is 0, no truncation on the clone(s) will be +/// performed. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct CloneSessionEntry { + #[prost(uint32, tag="1")] + pub session_id: u32, + #[prost(message, repeated, tag="2")] + pub replicas: ::prost::alloc::vec::Vec, + #[prost(uint32, tag="3")] + pub class_of_service: u32, + #[prost(int32, tag="4")] + pub packet_length_bytes: i32, +} +/// A member in a P4 value set. Each member defines a list of matches, which can +/// have different match types. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ValueSetMember { + #[prost(message, repeated, tag="1")] + pub r#match: ::prost::alloc::vec::Vec, +} +/// ------------------------------------------------------------------------------ +/// For writing and reading matches in a parser value set. A state transition +/// on an empty value set will never be taken. The number of matches must be at +/// most the size of the value set as specified by the size argument of the +/// value_set constructor in the P4 program. +/// +/// For Write Requests: +/// - MODIFY will write the given matches in the repeated field to the value +/// set. +/// - INSERT and DELETE are not allowed. +/// +/// For Read Requests: +/// - All matches for all value-set entries if value_set_id = 0 +/// - All matches of the value-set if a valid value_set_id is specified +/// - The 'match' field must never be set in the ReadRequest +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ValueSetEntry { + #[prost(uint32, tag="1")] + pub value_set_id: u32, + #[prost(message, repeated, tag="2")] + pub members: ::prost::alloc::vec::Vec, +} +/// ------------------------------------------------------------------------------ +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct RegisterEntry { + #[prost(uint32, tag="1")] + pub register_id: u32, + #[prost(message, optional, tag="2")] + pub index: ::core::option::Option, + #[prost(message, optional, tag="3")] + pub data: ::core::option::Option, +} +/// ------------------------------------------------------------------------------ +/// Used to configure the digest extern only, not to stream digests or acks +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct DigestEntry { + #[prost(uint32, tag="1")] + pub digest_id: u32, + #[prost(message, optional, tag="2")] + pub config: ::core::option::Option, +} +/// Nested message and enum types in `DigestEntry`. +pub mod digest_entry { + /// a DigestList message is streamed when the following conditions are met: + /// - there is at least one digest ready + /// - the oldest digest in the list has been waiting for at least + /// max_timeout_ns nanoseconds or we have gathered max_list_size digests + /// already + #[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] + pub struct Config { + /// max timeout for outstanding digest data + #[prost(int64, tag="1")] + pub max_timeout_ns: i64, + /// max size for a digest list + #[prost(int32, tag="2")] + pub max_list_size: i32, + /// timeout for DigestListAck message + #[prost(int64, tag="3")] + pub ack_timeout_ns: i64, + } +} +/// ------------------------------------------------------------------------------ +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct StreamMessageRequest { + #[prost(oneof="stream_message_request::Update", tags="1, 2, 3, 4")] + pub update: ::core::option::Option, +} +/// Nested message and enum types in `StreamMessageRequest`. +pub mod stream_message_request { + #[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Update { + #[prost(message, tag="1")] + Arbitration(super::MasterArbitrationUpdate), + #[prost(message, tag="2")] + Packet(super::PacketOut), + #[prost(message, tag="3")] + DigestAck(super::DigestListAck), + #[prost(message, tag="4")] + Other(::pbjson_types::Any), + } +} +/// Packet sent from the controller to the switch. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PacketOut { + #[prost(bytes="vec", tag="1")] + pub payload: ::prost::alloc::vec::Vec, + /// This will be based on P4 header annotated as + /// @controller_header("packet_out"). + /// At most one P4 header can have this annotation. + #[prost(message, repeated, tag="2")] + pub metadata: ::prost::alloc::vec::Vec, +} +/// Used by the controller to ack a DigestList message. To avoid flooding the +/// controller, the switch must not generate digest notifications for the same +/// data until a DigestListAck message with the same list_id is received or the +/// ack timeout (ack_timeout_ns field in DigestEntry.Config) expires. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct DigestListAck { + #[prost(uint32, tag="1")] + pub digest_id: u32, + #[prost(uint64, tag="2")] + pub list_id: u64, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct StreamMessageResponse { + #[prost(oneof="stream_message_response::Update", tags="1, 2, 3, 4, 5, 6")] + pub update: ::core::option::Option, +} +/// Nested message and enum types in `StreamMessageResponse`. +pub mod stream_message_response { + #[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Update { + #[prost(message, tag="1")] + Arbitration(super::MasterArbitrationUpdate), + #[prost(message, tag="2")] + Packet(super::PacketIn), + #[prost(message, tag="3")] + Digest(super::DigestList), + #[prost(message, tag="4")] + IdleTimeoutNotification(super::IdleTimeoutNotification), + #[prost(message, tag="5")] + Other(::pbjson_types::Any), + /// Used by the server to asynchronously report errors which occur when + /// processing StreamMessageRequest messages. + #[prost(message, tag="6")] + Error(super::StreamError), + } +} +/// Packet sent from the switch to the controller. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PacketIn { + #[prost(bytes="vec", tag="1")] + pub payload: ::prost::alloc::vec::Vec, + /// This will be based on P4 header annotated as + /// @controller_header("packet_in"). + /// At most one P4 header can have this annotation. + #[prost(message, repeated, tag="2")] + pub metadata: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct DigestList { + /// identifies the digest extern instance + #[prost(uint32, tag="1")] + pub digest_id: u32, + /// identifies a list of entries, used by receiver to ack + #[prost(uint64, tag="2")] + pub list_id: u64, + /// List of entries: each call to the Digest::pack() method corresponds to + /// one entry and we can have as little as one entry. + #[prost(message, repeated, tag="3")] + pub data: ::prost::alloc::vec::Vec, + /// Timestamp at which the server generated the message (in nanoseconds since + /// Epoch) + #[prost(int64, tag="4")] + pub timestamp: i64, +} +/// Any metadata associated with Packet-IO (controller Packet-In or Packet-Out) +/// needs to be modeled as P4 headers carrying special annotations +/// @controller_header("packet_out") and @controller_header("packet_in") +/// respectively. There can be at most one header each with these annotations. +/// These special headers are captured in P4Info ControllerPacketMetadata. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PacketMetadata { + /// This refers to Metadata.id coming from P4Info ControllerPacketMetadata. + #[prost(uint32, tag="1")] + pub metadata_id: u32, + #[prost(bytes="vec", tag="2")] + pub value: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct MasterArbitrationUpdate { + #[prost(uint64, tag="1")] + pub device_id: u64, + /// The role for which the primary client is being arbitrated. For use-cases + /// where multiple roles are not needed, the controller can leave this unset, + /// implying default role and full pipeline access. + #[prost(message, optional, tag="2")] + pub role: ::core::option::Option, + /// The stream RPC with the highest election_id is the primary. The 'primary' + /// controller instance populates this with its latest election_id. Switch + /// populates with the highest election ID it has received from all connected + /// controllers. + #[prost(message, optional, tag="3")] + pub election_id: ::core::option::Option, + /// Switch populates this with OK for the client that is the primary, and + /// with an error status for all other connected clients (at every primary + /// client change). The controller does not populate this field. + #[prost(message, optional, tag="4")] + pub status: ::core::option::Option, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Role { + /// Uniquely identifies this role. + #[deprecated] + #[prost(uint64, tag="1")] + pub id: u64, + #[prost(string, tag="3")] + pub name: ::prost::alloc::string::String, + /// Describes the role configuration, i.e. what operations, P4 entities, + /// behaviors, etc. are in the scope of a given role. If config is not set + /// (default case), it implies all P4 objects and control behaviors are in + /// scope, i.e. full pipeline access. The format of this message is + /// out-of-scope of P4Runtime. + #[prost(message, optional, tag="2")] + pub config: ::core::option::Option<::pbjson_types::Any>, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct IdleTimeoutNotification { + /// The only fields that are required to be set in each TableEntry are the + /// "key" fields (table_id, match and priority) along with controller_metadata, + /// metadata and idle_timeout_ns. + #[prost(message, repeated, tag="1")] + pub table_entry: ::prost::alloc::vec::Vec, + /// Timestamp at which the server generated the message (in nanoseconds since + /// Epoch) + #[prost(int64, tag="2")] + pub timestamp: i64, +} +/// Used by the server to asynchronously report errors which occur when +/// processing StreamMessageRequest messages. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct StreamError { + /// gRPC canonical error code (see + /// ) + #[prost(int32, tag="1")] + pub canonical_code: i32, + /// Optional. An explanation of the error. + #[prost(string, tag="2")] + pub message: ::prost::alloc::string::String, + /// Optional. Target and architecture specific space to which this error + /// belongs. + /// We encourage using triplet: --, + /// e.g."targetX-psa-vendor1" or "targetY-psa-vendor2". + #[prost(string, tag="3")] + pub space: ::prost::alloc::string::String, + /// Optional. Numeric code drawn from target-specific error space above. + #[prost(int32, tag="4")] + pub code: i32, + /// Used by the server to convey additional information about the error. One of + /// the fields must be set (so that the client can identify which type of + /// stream message triggered the error), but that field may be set to its + /// default value. + #[prost(oneof="stream_error::Details", tags="5, 6, 7")] + pub details: ::core::option::Option, +} +/// Nested message and enum types in `StreamError`. +pub mod stream_error { + /// Used by the server to convey additional information about the error. One of + /// the fields must be set (so that the client can identify which type of + /// stream message triggered the error), but that field may be set to its + /// default value. + #[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Details { + #[prost(message, tag="5")] + PacketOut(super::PacketOutError), + #[prost(message, tag="6")] + DigestListAck(super::DigestListAckError), + #[prost(message, tag="7")] + Other(super::StreamOtherError), + } +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PacketOutError { + /// Optional. The packet out message that caused the error. + #[prost(message, optional, tag="1")] + pub packet_out: ::core::option::Option, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct DigestListAckError { + /// Optional. The digest list acknowledgement message that caused the error. + #[prost(message, optional, tag="1")] + pub digest_list_ack: ::core::option::Option, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct StreamOtherError { + /// Optional. The architecture-specific stream message that caused the error. + #[prost(message, optional, tag="1")] + pub other: ::core::option::Option<::pbjson_types::Any>, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Uint128 { + /// Highest 64 bits of a 128 bit number. + #[prost(uint64, tag="1")] + pub high: u64, + /// Lowest 64 bits of a 128 bit number. + #[prost(uint64, tag="2")] + pub low: u64, +} +/// ------------------------------------------------------------------------------ +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct SetForwardingPipelineConfigRequest { + #[prost(uint64, tag="1")] + pub device_id: u64, + #[deprecated] + #[prost(uint64, tag="2")] + pub role_id: u64, + #[prost(string, tag="6")] + pub role: ::prost::alloc::string::String, + #[prost(message, optional, tag="3")] + pub election_id: ::core::option::Option, + #[prost(enumeration="set_forwarding_pipeline_config_request::Action", tag="4")] + pub action: i32, + #[prost(message, optional, tag="5")] + pub config: ::core::option::Option, +} +/// Nested message and enum types in `SetForwardingPipelineConfigRequest`. +pub mod set_forwarding_pipeline_config_request { + #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] + #[repr(i32)] + pub enum Action { + Unspecified = 0, + /// Verify that the target can realize the given config. Do not modify the + /// forwarding state in the target. Returns error if config is not provided + /// of if the provided config cannot be realized. + Verify = 1, + /// Save the config if the target can realize it. Do not modify the + /// forwarding state in the target. Any subsequent read/write requests must + /// refer to fields in the new config. Returns error if config is not + /// provided of if the provided config cannot be realized. + VerifyAndSave = 2, + /// Verify, save and realize the given config. Clear the forwarding state + /// in the target. Returns error if config is not provided of if the + /// provided config cannot be realized. + VerifyAndCommit = 3, + /// Realize the last saved, but not yet committed, config. Update the + /// forwarding state in the target by replaying the write requests since the + /// last config was saved. Config should not be provided for this action + /// type. Returns an error if no saved config is found or if a config is + /// provided with this message. + Commit = 4, + /// Verify, save and realize the given config, while preserving the + /// forwarding state in the target. This is an advanced use case to enable + /// changes to the P4 forwarding pipeline configuration with minimal traffic + /// loss. P4Runtime does not impose any constraints on the duration of the + /// traffic loss. The support for this option is not expected to be uniform + /// across all P4Runtime targets. A target that does not support this option + /// may return an UNIMPLEMENTED error. For targets that support this option, + /// an INVALID_ARGUMENT error is returned if no config is provided, or if + /// the existing forwarding state cannot be preserved for the given config + /// by the target. + ReconcileAndCommit = 5, + } + impl Action { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + Action::Unspecified => "UNSPECIFIED", + Action::Verify => "VERIFY", + Action::VerifyAndSave => "VERIFY_AND_SAVE", + Action::VerifyAndCommit => "VERIFY_AND_COMMIT", + Action::Commit => "COMMIT", + Action::ReconcileAndCommit => "RECONCILE_AND_COMMIT", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "UNSPECIFIED" => Some(Self::Unspecified), + "VERIFY" => Some(Self::Verify), + "VERIFY_AND_SAVE" => Some(Self::VerifyAndSave), + "VERIFY_AND_COMMIT" => Some(Self::VerifyAndCommit), + "COMMIT" => Some(Self::Commit), + "RECONCILE_AND_COMMIT" => Some(Self::ReconcileAndCommit), + _ => None, + } + } + } +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct SetForwardingPipelineConfigResponse { +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ForwardingPipelineConfig { + #[prost(message, optional, tag="1")] + pub p4info: ::core::option::Option, + /// Target-specific P4 configuration. + #[prost(bytes="vec", tag="2")] + pub p4_device_config: ::prost::alloc::vec::Vec, + #[prost(message, optional, tag="3")] + pub cookie: ::core::option::Option, +} +/// Nested message and enum types in `ForwardingPipelineConfig`. +pub mod forwarding_pipeline_config { + /// Metadata (cookie) opaque to the target. A control plane may use this field + /// to uniquely identify this config. There are no restrictions on how such + /// value is computed, or where this is stored on the target, as long as it is + /// returned with a GetForwardingPipelineConfig RPC. When reading the cookie, + /// we need to distinguish those cases where a cookie is NOT present (e.g. not + /// set in the SetForwardingPipelineConfigRequest, therefore we wrap the actual + /// uint64 value in a protobuf message. + #[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] + pub struct Cookie { + #[prost(uint64, tag="1")] + pub cookie: u64, + } +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetForwardingPipelineConfigRequest { + #[prost(uint64, tag="1")] + pub device_id: u64, + #[prost(enumeration="get_forwarding_pipeline_config_request::ResponseType", tag="2")] + pub response_type: i32, +} +/// Nested message and enum types in `GetForwardingPipelineConfigRequest`. +pub mod get_forwarding_pipeline_config_request { + /// Specifies the fields to populate in the response. + #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] + #[repr(i32)] + pub enum ResponseType { + /// Default behaviour. Returns a ForwardingPipelineConfig with all fields set + /// as stored by the target. + All = 0, + /// Reply by setting only the cookie field, omitting all other fields. + CookieOnly = 1, + /// Reply by setting the p4info and cookie fields. + P4infoAndCookie = 2, + /// Reply by setting the p4_device_config and cookie fields. + DeviceConfigAndCookie = 3, + } + impl ResponseType { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + ResponseType::All => "ALL", + ResponseType::CookieOnly => "COOKIE_ONLY", + ResponseType::P4infoAndCookie => "P4INFO_AND_COOKIE", + ResponseType::DeviceConfigAndCookie => "DEVICE_CONFIG_AND_COOKIE", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "ALL" => Some(Self::All), + "COOKIE_ONLY" => Some(Self::CookieOnly), + "P4INFO_AND_COOKIE" => Some(Self::P4infoAndCookie), + "DEVICE_CONFIG_AND_COOKIE" => Some(Self::DeviceConfigAndCookie), + _ => None, + } + } + } +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetForwardingPipelineConfigResponse { + #[prost(message, optional, tag="1")] + pub config: ::core::option::Option, +} +/// Error message used to report a single P4-entity error for a Write RPC. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Error { + /// gRPC canonical error code (see + /// ) + #[prost(int32, tag="1")] + pub canonical_code: i32, + /// Detailed error message. + #[prost(string, tag="2")] + pub message: ::prost::alloc::string::String, + /// Target and architecture specific space to which this error belongs. + /// We encourage using triplet: --, + /// e.g."targetX-psa-vendor1" or "targetY-psa-vendor2". + #[prost(string, tag="3")] + pub space: ::prost::alloc::string::String, + /// Numeric code drawn from target-specific error space above. + #[prost(int32, tag="4")] + pub code: i32, + /// Optional: Allows reporting back additional target-specific details on the + /// error. + #[prost(message, optional, tag="5")] + pub details: ::core::option::Option<::pbjson_types::Any>, +} +/// ------------------------------------------------------------------------------ +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct CapabilitiesRequest { +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct CapabilitiesResponse { + /// The full semantic version string (e.g. "1.1.0-rc.1") corresponding to the + /// version of the P4Runtime API currently implemented by the server. + #[prost(string, tag="1")] + pub p4runtime_api_version: ::prost::alloc::string::String, +} +/// ------------------------------------------------------------------------------ +/// Reserved controller-specified SDN port numbers for reference. +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum SdnPort { + Unknown = 0, + /// SDN ports are numbered starting form 1. + Min = 1, + /// 0xfffffeff: The maximum value of an SDN port (physical or logical). + Max = -257, + /// Reserved SDN port numbers (0xffffff00 - 0xffffffff) + /// 0xfffffffa: Recirculate the packet back to ingress + Recirculate = -6, + /// 0xfffffffd: Send to CPU + Cpu = -3, +} +impl SdnPort { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + SdnPort::Unknown => "SDN_PORT_UNKNOWN", + SdnPort::Min => "SDN_PORT_MIN", + SdnPort::Max => "SDN_PORT_MAX", + SdnPort::Recirculate => "SDN_PORT_RECIRCULATE", + SdnPort::Cpu => "SDN_PORT_CPU", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "SDN_PORT_UNKNOWN" => Some(Self::Unknown), + "SDN_PORT_MIN" => Some(Self::Min), + "SDN_PORT_MAX" => Some(Self::Max), + "SDN_PORT_RECIRCULATE" => Some(Self::Recirculate), + "SDN_PORT_CPU" => Some(Self::Cpu), + _ => None, + } + } +} +include!("p4.v1.tonic.rs"); +// @@protoc_insertion_point(module) diff --git a/rust/src/p4.v1.tonic.rs b/rust/src/p4.v1.tonic.rs new file mode 100644 index 00000000..29e98fb5 --- /dev/null +++ b/rust/src/p4.v1.tonic.rs @@ -0,0 +1,703 @@ +// @generated +/// Generated client implementations. +pub mod p4_runtime_client { + #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] + use tonic::codegen::*; + use tonic::codegen::http::Uri; + #[derive(Debug, Clone)] + pub struct P4RuntimeClient { + inner: tonic::client::Grpc, + } + impl P4RuntimeClient { + /// Attempt to create a new client by connecting to a given endpoint. + pub async fn connect(dst: D) -> Result + where + D: TryInto, + D::Error: Into, + { + let conn = tonic::transport::Endpoint::new(dst)?.connect().await?; + Ok(Self::new(conn)) + } + } + impl P4RuntimeClient + where + T: tonic::client::GrpcService, + T::Error: Into, + T::ResponseBody: Body + Send + 'static, + ::Error: Into + Send, + { + pub fn new(inner: T) -> Self { + let inner = tonic::client::Grpc::new(inner); + Self { inner } + } + pub fn with_origin(inner: T, origin: Uri) -> Self { + let inner = tonic::client::Grpc::with_origin(inner, origin); + Self { inner } + } + pub fn with_interceptor( + inner: T, + interceptor: F, + ) -> P4RuntimeClient> + where + F: tonic::service::Interceptor, + T::ResponseBody: Default, + T: tonic::codegen::Service< + http::Request, + Response = http::Response< + >::ResponseBody, + >, + >, + , + >>::Error: Into + Send + Sync, + { + P4RuntimeClient::new(InterceptedService::new(inner, interceptor)) + } + /// Compress requests with the given encoding. + /// + /// This requires the server to support it otherwise it might respond with an + /// error. + #[must_use] + pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.inner = self.inner.send_compressed(encoding); + self + } + /// Enable decompressing responses. + #[must_use] + pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.inner = self.inner.accept_compressed(encoding); + self + } + /// Limits the maximum size of a decoded message. + /// + /// Default: `4MB` + #[must_use] + pub fn max_decoding_message_size(mut self, limit: usize) -> Self { + self.inner = self.inner.max_decoding_message_size(limit); + self + } + /// Limits the maximum size of an encoded message. + /// + /// Default: `usize::MAX` + #[must_use] + pub fn max_encoding_message_size(mut self, limit: usize) -> Self { + self.inner = self.inner.max_encoding_message_size(limit); + self + } + pub async fn write( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result, tonic::Status> { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static("/p4.v1.P4Runtime/Write"); + let mut req = request.into_request(); + req.extensions_mut().insert(GrpcMethod::new("p4.v1.P4Runtime", "Write")); + self.inner.unary(req, path, codec).await + } + pub async fn read( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result< + tonic::Response>, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static("/p4.v1.P4Runtime/Read"); + let mut req = request.into_request(); + req.extensions_mut().insert(GrpcMethod::new("p4.v1.P4Runtime", "Read")); + self.inner.server_streaming(req, path, codec).await + } + pub async fn set_forwarding_pipeline_config( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/p4.v1.P4Runtime/SetForwardingPipelineConfig", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new("p4.v1.P4Runtime", "SetForwardingPipelineConfig"), + ); + self.inner.unary(req, path, codec).await + } + pub async fn get_forwarding_pipeline_config( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/p4.v1.P4Runtime/GetForwardingPipelineConfig", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new("p4.v1.P4Runtime", "GetForwardingPipelineConfig"), + ); + self.inner.unary(req, path, codec).await + } + pub async fn stream_channel( + &mut self, + request: impl tonic::IntoStreamingRequest< + Message = super::StreamMessageRequest, + >, + ) -> std::result::Result< + tonic::Response>, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/p4.v1.P4Runtime/StreamChannel", + ); + let mut req = request.into_streaming_request(); + req.extensions_mut() + .insert(GrpcMethod::new("p4.v1.P4Runtime", "StreamChannel")); + self.inner.streaming(req, path, codec).await + } + pub async fn capabilities( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/p4.v1.P4Runtime/Capabilities", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert(GrpcMethod::new("p4.v1.P4Runtime", "Capabilities")); + self.inner.unary(req, path, codec).await + } + } +} +/// Generated server implementations. +pub mod p4_runtime_server { + #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] + use tonic::codegen::*; + /// Generated trait containing gRPC methods that should be implemented for use with P4RuntimeServer. + #[async_trait] + pub trait P4Runtime: Send + Sync + 'static { + async fn write( + &self, + request: tonic::Request, + ) -> std::result::Result, tonic::Status>; + /// Server streaming response type for the Read method. + type ReadStream: tonic::codegen::tokio_stream::Stream< + Item = std::result::Result, + > + + Send + + 'static; + async fn read( + &self, + request: tonic::Request, + ) -> std::result::Result, tonic::Status>; + async fn set_forwarding_pipeline_config( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; + async fn get_forwarding_pipeline_config( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; + /// Server streaming response type for the StreamChannel method. + type StreamChannelStream: tonic::codegen::tokio_stream::Stream< + Item = std::result::Result, + > + + Send + + 'static; + async fn stream_channel( + &self, + request: tonic::Request>, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; + async fn capabilities( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; + } + #[derive(Debug)] + pub struct P4RuntimeServer { + inner: _Inner, + accept_compression_encodings: EnabledCompressionEncodings, + send_compression_encodings: EnabledCompressionEncodings, + max_decoding_message_size: Option, + max_encoding_message_size: Option, + } + struct _Inner(Arc); + impl P4RuntimeServer { + pub fn new(inner: T) -> Self { + Self::from_arc(Arc::new(inner)) + } + pub fn from_arc(inner: Arc) -> Self { + let inner = _Inner(inner); + Self { + inner, + accept_compression_encodings: Default::default(), + send_compression_encodings: Default::default(), + max_decoding_message_size: None, + max_encoding_message_size: None, + } + } + pub fn with_interceptor( + inner: T, + interceptor: F, + ) -> InterceptedService + where + F: tonic::service::Interceptor, + { + InterceptedService::new(Self::new(inner), interceptor) + } + /// Enable decompressing requests with the given encoding. + #[must_use] + pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.accept_compression_encodings.enable(encoding); + self + } + /// Compress responses with the given encoding, if the client supports it. + #[must_use] + pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.send_compression_encodings.enable(encoding); + self + } + /// Limits the maximum size of a decoded message. + /// + /// Default: `4MB` + #[must_use] + pub fn max_decoding_message_size(mut self, limit: usize) -> Self { + self.max_decoding_message_size = Some(limit); + self + } + /// Limits the maximum size of an encoded message. + /// + /// Default: `usize::MAX` + #[must_use] + pub fn max_encoding_message_size(mut self, limit: usize) -> Self { + self.max_encoding_message_size = Some(limit); + self + } + } + impl tonic::codegen::Service> for P4RuntimeServer + where + T: P4Runtime, + B: Body + Send + 'static, + B::Error: Into + Send + 'static, + { + type Response = http::Response; + type Error = std::convert::Infallible; + type Future = BoxFuture; + fn poll_ready( + &mut self, + _cx: &mut Context<'_>, + ) -> Poll> { + Poll::Ready(Ok(())) + } + fn call(&mut self, req: http::Request) -> Self::Future { + let inner = self.inner.clone(); + match req.uri().path() { + "/p4.v1.P4Runtime/Write" => { + #[allow(non_camel_case_types)] + struct WriteSvc(pub Arc); + impl tonic::server::UnaryService + for WriteSvc { + type Response = super::WriteResponse; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::write(&inner, request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let inner = inner.0; + let method = WriteSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/p4.v1.P4Runtime/Read" => { + #[allow(non_camel_case_types)] + struct ReadSvc(pub Arc); + impl< + T: P4Runtime, + > tonic::server::ServerStreamingService + for ReadSvc { + type Response = super::ReadResponse; + type ResponseStream = T::ReadStream; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::read(&inner, request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let inner = inner.0; + let method = ReadSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.server_streaming(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/p4.v1.P4Runtime/SetForwardingPipelineConfig" => { + #[allow(non_camel_case_types)] + struct SetForwardingPipelineConfigSvc(pub Arc); + impl< + T: P4Runtime, + > tonic::server::UnaryService< + super::SetForwardingPipelineConfigRequest, + > for SetForwardingPipelineConfigSvc { + type Response = super::SetForwardingPipelineConfigResponse; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request< + super::SetForwardingPipelineConfigRequest, + >, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::set_forwarding_pipeline_config( + &inner, + request, + ) + .await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let inner = inner.0; + let method = SetForwardingPipelineConfigSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/p4.v1.P4Runtime/GetForwardingPipelineConfig" => { + #[allow(non_camel_case_types)] + struct GetForwardingPipelineConfigSvc(pub Arc); + impl< + T: P4Runtime, + > tonic::server::UnaryService< + super::GetForwardingPipelineConfigRequest, + > for GetForwardingPipelineConfigSvc { + type Response = super::GetForwardingPipelineConfigResponse; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request< + super::GetForwardingPipelineConfigRequest, + >, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::get_forwarding_pipeline_config( + &inner, + request, + ) + .await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let inner = inner.0; + let method = GetForwardingPipelineConfigSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/p4.v1.P4Runtime/StreamChannel" => { + #[allow(non_camel_case_types)] + struct StreamChannelSvc(pub Arc); + impl< + T: P4Runtime, + > tonic::server::StreamingService + for StreamChannelSvc { + type Response = super::StreamMessageResponse; + type ResponseStream = T::StreamChannelStream; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request< + tonic::Streaming, + >, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::stream_channel(&inner, request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let inner = inner.0; + let method = StreamChannelSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.streaming(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/p4.v1.P4Runtime/Capabilities" => { + #[allow(non_camel_case_types)] + struct CapabilitiesSvc(pub Arc); + impl< + T: P4Runtime, + > tonic::server::UnaryService + for CapabilitiesSvc { + type Response = super::CapabilitiesResponse; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::capabilities(&inner, request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let inner = inner.0; + let method = CapabilitiesSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + _ => { + Box::pin(async move { + Ok( + http::Response::builder() + .status(200) + .header("grpc-status", "12") + .header("content-type", "application/grpc") + .body(empty_body()) + .unwrap(), + ) + }) + } + } + } + } + impl Clone for P4RuntimeServer { + fn clone(&self) -> Self { + let inner = self.inner.clone(); + Self { + inner, + accept_compression_encodings: self.accept_compression_encodings, + send_compression_encodings: self.send_compression_encodings, + max_decoding_message_size: self.max_decoding_message_size, + max_encoding_message_size: self.max_encoding_message_size, + } + } + } + impl Clone for _Inner { + fn clone(&self) -> Self { + Self(Arc::clone(&self.0)) + } + } + impl std::fmt::Debug for _Inner { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{:?}", self.0) + } + } + impl tonic::server::NamedService for P4RuntimeServer { + const NAME: &'static str = "p4.v1.P4Runtime"; + } +}