diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index da9683f9..7a3e8e07 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -157,6 +157,9 @@ jobs: - name: Package (docs) run: cargo doc --no-deps --target=wasm32-unknown-unknown + - name: Test (docs) + run: cargo test --doc + - name: Package (publish) run: cargo publish --dry-run --target=wasm32-unknown-unknown @@ -219,6 +222,9 @@ jobs: - name: Package (docs) run: cargo doc --no-deps --target=wasm32-unknown-unknown + - name: Test (docs) + run: cargo test --doc + - name: Package (publish) run: cargo publish --dry-run --target=wasm32-unknown-unknown @@ -282,6 +288,9 @@ jobs: - name: Package (docs) run: cargo doc --no-deps --target=wasm32-unknown-unknown + - name: Test (docs) + run: cargo test --doc + - name: Package (publish) run: cargo publish --dry-run --target=wasm32-unknown-unknown diff --git a/Cargo.toml b/Cargo.toml index 24193eb8..d36c72c5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,6 +14,10 @@ build = "build.rs" hashbrown = "0.15" log = "0.4" +[dev-dependencies] +serde = { version = "1.0.210", features = ["derive"] } +serde_json = "1.0.128" + [profile.release] lto = true opt-level = 3 diff --git a/bazel/cargo/Cargo.Bazel.lock b/bazel/cargo/Cargo.Bazel.lock index f4d451ea..a42c44c4 100644 --- a/bazel/cargo/Cargo.Bazel.lock +++ b/bazel/cargo/Cargo.Bazel.lock @@ -31,16 +31,103 @@ dependencies = [ "foldhash", ] +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + [[package]] name = "log" version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "proc-macro2" +version = "1.0.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" +dependencies = [ + "unicode-ident", +] + [[package]] name = "proxy-wasm" version = "0.2.3-dev" dependencies = [ "hashbrown", "log", + "serde", + "serde_json", +] + +[[package]] +name = "quote" +version = "1.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] +name = "serde" +version = "1.0.214" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f55c3193aca71c12ad7890f1785d2b73e1b9f63a0bbc353c08ef26fe03fc56b5" +dependencies = [ + "serde_derive", ] + +[[package]] +name = "serde_derive" +version = "1.0.214" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de523f781f095e28fa605cdce0f8307e451cc0fd14e2eb4cd2e98a355b147766" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.132" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", +] + +[[package]] +name = "syn" +version = "2.0.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "unicode-ident" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" diff --git a/bazel/cargo/remote/BUILD.bazel b/bazel/cargo/remote/BUILD.bazel index f62c1da8..336166ca 100644 --- a/bazel/cargo/remote/BUILD.bazel +++ b/bazel/cargo/remote/BUILD.bazel @@ -48,3 +48,15 @@ alias( actual = "@crates_vendor__proxy-wasm-0.2.3-dev//:proxy_wasm", tags = ["manual"], ) + +alias( + name = "serde", + actual = "@crates_vendor__serde-1.0.214//:serde", + tags = ["manual"], +) + +alias( + name = "serde_json", + actual = "@crates_vendor__serde_json-1.0.132//:serde_json", + tags = ["manual"], +) diff --git a/bazel/cargo/remote/BUILD.itoa-1.0.11.bazel b/bazel/cargo/remote/BUILD.itoa-1.0.11.bazel new file mode 100644 index 00000000..d8c549e8 --- /dev/null +++ b/bazel/cargo/remote/BUILD.itoa-1.0.11.bazel @@ -0,0 +1,81 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "itoa", + srcs = glob( + include = ["**/*.rs"], + allow_empty = True, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=itoa", + "manual", + "noclippy", + "norustfmt", + ], + target_compatible_with = select({ + "@rules_rust//rust/platform:aarch64-apple-darwin": [], + "@rules_rust//rust/platform:aarch64-apple-ios": [], + "@rules_rust//rust/platform:aarch64-apple-ios-sim": [], + "@rules_rust//rust/platform:aarch64-fuchsia": [], + "@rules_rust//rust/platform:aarch64-linux-android": [], + "@rules_rust//rust/platform:aarch64-pc-windows-msvc": [], + "@rules_rust//rust/platform:aarch64-unknown-linux-gnu": [], + "@rules_rust//rust/platform:aarch64-unknown-nixos-gnu": [], + "@rules_rust//rust/platform:aarch64-unknown-nto-qnx710": [], + "@rules_rust//rust/platform:arm-unknown-linux-gnueabi": [], + "@rules_rust//rust/platform:armv7-linux-androideabi": [], + "@rules_rust//rust/platform:armv7-unknown-linux-gnueabi": [], + "@rules_rust//rust/platform:i686-apple-darwin": [], + "@rules_rust//rust/platform:i686-linux-android": [], + "@rules_rust//rust/platform:i686-pc-windows-msvc": [], + "@rules_rust//rust/platform:i686-unknown-freebsd": [], + "@rules_rust//rust/platform:i686-unknown-linux-gnu": [], + "@rules_rust//rust/platform:powerpc-unknown-linux-gnu": [], + "@rules_rust//rust/platform:riscv32imc-unknown-none-elf": [], + "@rules_rust//rust/platform:riscv64gc-unknown-none-elf": [], + "@rules_rust//rust/platform:s390x-unknown-linux-gnu": [], + "@rules_rust//rust/platform:thumbv7em-none-eabi": [], + "@rules_rust//rust/platform:thumbv8m.main-none-eabi": [], + "@rules_rust//rust/platform:wasm32-unknown-unknown": [], + "@rules_rust//rust/platform:wasm32-wasi": [], + "@rules_rust//rust/platform:x86_64-apple-darwin": [], + "@rules_rust//rust/platform:x86_64-apple-ios": [], + "@rules_rust//rust/platform:x86_64-fuchsia": [], + "@rules_rust//rust/platform:x86_64-linux-android": [], + "@rules_rust//rust/platform:x86_64-pc-windows-msvc": [], + "@rules_rust//rust/platform:x86_64-unknown-freebsd": [], + "@rules_rust//rust/platform:x86_64-unknown-linux-gnu": [], + "@rules_rust//rust/platform:x86_64-unknown-nixos-gnu": [], + "@rules_rust//rust/platform:x86_64-unknown-none": [], + "//conditions:default": ["@platforms//:incompatible"], + }), + version = "1.0.11", +) diff --git a/bazel/cargo/remote/BUILD.memchr-2.7.4.bazel b/bazel/cargo/remote/BUILD.memchr-2.7.4.bazel new file mode 100644 index 00000000..be1aa06f --- /dev/null +++ b/bazel/cargo/remote/BUILD.memchr-2.7.4.bazel @@ -0,0 +1,85 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "memchr", + srcs = glob( + include = ["**/*.rs"], + allow_empty = True, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "alloc", + "std", + ], + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=memchr", + "manual", + "noclippy", + "norustfmt", + ], + target_compatible_with = select({ + "@rules_rust//rust/platform:aarch64-apple-darwin": [], + "@rules_rust//rust/platform:aarch64-apple-ios": [], + "@rules_rust//rust/platform:aarch64-apple-ios-sim": [], + "@rules_rust//rust/platform:aarch64-fuchsia": [], + "@rules_rust//rust/platform:aarch64-linux-android": [], + "@rules_rust//rust/platform:aarch64-pc-windows-msvc": [], + "@rules_rust//rust/platform:aarch64-unknown-linux-gnu": [], + "@rules_rust//rust/platform:aarch64-unknown-nixos-gnu": [], + "@rules_rust//rust/platform:aarch64-unknown-nto-qnx710": [], + "@rules_rust//rust/platform:arm-unknown-linux-gnueabi": [], + "@rules_rust//rust/platform:armv7-linux-androideabi": [], + "@rules_rust//rust/platform:armv7-unknown-linux-gnueabi": [], + "@rules_rust//rust/platform:i686-apple-darwin": [], + "@rules_rust//rust/platform:i686-linux-android": [], + "@rules_rust//rust/platform:i686-pc-windows-msvc": [], + "@rules_rust//rust/platform:i686-unknown-freebsd": [], + "@rules_rust//rust/platform:i686-unknown-linux-gnu": [], + "@rules_rust//rust/platform:powerpc-unknown-linux-gnu": [], + "@rules_rust//rust/platform:riscv32imc-unknown-none-elf": [], + "@rules_rust//rust/platform:riscv64gc-unknown-none-elf": [], + "@rules_rust//rust/platform:s390x-unknown-linux-gnu": [], + "@rules_rust//rust/platform:thumbv7em-none-eabi": [], + "@rules_rust//rust/platform:thumbv8m.main-none-eabi": [], + "@rules_rust//rust/platform:wasm32-unknown-unknown": [], + "@rules_rust//rust/platform:wasm32-wasi": [], + "@rules_rust//rust/platform:x86_64-apple-darwin": [], + "@rules_rust//rust/platform:x86_64-apple-ios": [], + "@rules_rust//rust/platform:x86_64-fuchsia": [], + "@rules_rust//rust/platform:x86_64-linux-android": [], + "@rules_rust//rust/platform:x86_64-pc-windows-msvc": [], + "@rules_rust//rust/platform:x86_64-unknown-freebsd": [], + "@rules_rust//rust/platform:x86_64-unknown-linux-gnu": [], + "@rules_rust//rust/platform:x86_64-unknown-nixos-gnu": [], + "@rules_rust//rust/platform:x86_64-unknown-none": [], + "//conditions:default": ["@platforms//:incompatible"], + }), + version = "2.7.4", +) diff --git a/bazel/cargo/remote/BUILD.proc-macro2-1.0.89.bazel b/bazel/cargo/remote/BUILD.proc-macro2-1.0.89.bazel new file mode 100644 index 00000000..8c8e666c --- /dev/null +++ b/bazel/cargo/remote/BUILD.proc-macro2-1.0.89.bazel @@ -0,0 +1,147 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo:crates_vendor +############################################################################### + +load("@rules_rust//cargo:defs.bzl", "cargo_build_script") +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "proc_macro2", + srcs = glob( + include = ["**/*.rs"], + allow_empty = True, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "proc-macro", + ], + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=proc-macro2", + "manual", + "noclippy", + "norustfmt", + ], + target_compatible_with = select({ + "@rules_rust//rust/platform:aarch64-apple-darwin": [], + "@rules_rust//rust/platform:aarch64-apple-ios": [], + "@rules_rust//rust/platform:aarch64-apple-ios-sim": [], + "@rules_rust//rust/platform:aarch64-fuchsia": [], + "@rules_rust//rust/platform:aarch64-linux-android": [], + "@rules_rust//rust/platform:aarch64-pc-windows-msvc": [], + "@rules_rust//rust/platform:aarch64-unknown-linux-gnu": [], + "@rules_rust//rust/platform:aarch64-unknown-nixos-gnu": [], + "@rules_rust//rust/platform:aarch64-unknown-nto-qnx710": [], + "@rules_rust//rust/platform:arm-unknown-linux-gnueabi": [], + "@rules_rust//rust/platform:armv7-linux-androideabi": [], + "@rules_rust//rust/platform:armv7-unknown-linux-gnueabi": [], + "@rules_rust//rust/platform:i686-apple-darwin": [], + "@rules_rust//rust/platform:i686-linux-android": [], + "@rules_rust//rust/platform:i686-pc-windows-msvc": [], + "@rules_rust//rust/platform:i686-unknown-freebsd": [], + "@rules_rust//rust/platform:i686-unknown-linux-gnu": [], + "@rules_rust//rust/platform:powerpc-unknown-linux-gnu": [], + "@rules_rust//rust/platform:riscv32imc-unknown-none-elf": [], + "@rules_rust//rust/platform:riscv64gc-unknown-none-elf": [], + "@rules_rust//rust/platform:s390x-unknown-linux-gnu": [], + "@rules_rust//rust/platform:thumbv7em-none-eabi": [], + "@rules_rust//rust/platform:thumbv8m.main-none-eabi": [], + "@rules_rust//rust/platform:wasm32-unknown-unknown": [], + "@rules_rust//rust/platform:wasm32-wasi": [], + "@rules_rust//rust/platform:x86_64-apple-darwin": [], + "@rules_rust//rust/platform:x86_64-apple-ios": [], + "@rules_rust//rust/platform:x86_64-fuchsia": [], + "@rules_rust//rust/platform:x86_64-linux-android": [], + "@rules_rust//rust/platform:x86_64-pc-windows-msvc": [], + "@rules_rust//rust/platform:x86_64-unknown-freebsd": [], + "@rules_rust//rust/platform:x86_64-unknown-linux-gnu": [], + "@rules_rust//rust/platform:x86_64-unknown-nixos-gnu": [], + "@rules_rust//rust/platform:x86_64-unknown-none": [], + "//conditions:default": ["@platforms//:incompatible"], + }), + version = "1.0.89", + deps = [ + "@crates_vendor__proc-macro2-1.0.89//:build_script_build", + "@crates_vendor__unicode-ident-1.0.13//:unicode_ident", + ], +) + +cargo_build_script( + name = "_bs", + srcs = glob( + include = ["**/*.rs"], + allow_empty = True, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + "**/*.rs", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "proc-macro", + ], + crate_name = "build_script_build", + crate_root = "build.rs", + data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + edition = "2021", + pkg_name = "proc-macro2", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=proc-macro2", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.0.89", + visibility = ["//visibility:private"], +) + +alias( + name = "build_script_build", + actual = ":_bs", + tags = ["manual"], +) diff --git a/bazel/cargo/remote/BUILD.quote-1.0.37.bazel b/bazel/cargo/remote/BUILD.quote-1.0.37.bazel new file mode 100644 index 00000000..1c6217c9 --- /dev/null +++ b/bazel/cargo/remote/BUILD.quote-1.0.37.bazel @@ -0,0 +1,87 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "quote", + srcs = glob( + include = ["**/*.rs"], + allow_empty = True, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "proc-macro", + ], + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=quote", + "manual", + "noclippy", + "norustfmt", + ], + target_compatible_with = select({ + "@rules_rust//rust/platform:aarch64-apple-darwin": [], + "@rules_rust//rust/platform:aarch64-apple-ios": [], + "@rules_rust//rust/platform:aarch64-apple-ios-sim": [], + "@rules_rust//rust/platform:aarch64-fuchsia": [], + "@rules_rust//rust/platform:aarch64-linux-android": [], + "@rules_rust//rust/platform:aarch64-pc-windows-msvc": [], + "@rules_rust//rust/platform:aarch64-unknown-linux-gnu": [], + "@rules_rust//rust/platform:aarch64-unknown-nixos-gnu": [], + "@rules_rust//rust/platform:aarch64-unknown-nto-qnx710": [], + "@rules_rust//rust/platform:arm-unknown-linux-gnueabi": [], + "@rules_rust//rust/platform:armv7-linux-androideabi": [], + "@rules_rust//rust/platform:armv7-unknown-linux-gnueabi": [], + "@rules_rust//rust/platform:i686-apple-darwin": [], + "@rules_rust//rust/platform:i686-linux-android": [], + "@rules_rust//rust/platform:i686-pc-windows-msvc": [], + "@rules_rust//rust/platform:i686-unknown-freebsd": [], + "@rules_rust//rust/platform:i686-unknown-linux-gnu": [], + "@rules_rust//rust/platform:powerpc-unknown-linux-gnu": [], + "@rules_rust//rust/platform:riscv32imc-unknown-none-elf": [], + "@rules_rust//rust/platform:riscv64gc-unknown-none-elf": [], + "@rules_rust//rust/platform:s390x-unknown-linux-gnu": [], + "@rules_rust//rust/platform:thumbv7em-none-eabi": [], + "@rules_rust//rust/platform:thumbv8m.main-none-eabi": [], + "@rules_rust//rust/platform:wasm32-unknown-unknown": [], + "@rules_rust//rust/platform:wasm32-wasi": [], + "@rules_rust//rust/platform:x86_64-apple-darwin": [], + "@rules_rust//rust/platform:x86_64-apple-ios": [], + "@rules_rust//rust/platform:x86_64-fuchsia": [], + "@rules_rust//rust/platform:x86_64-linux-android": [], + "@rules_rust//rust/platform:x86_64-pc-windows-msvc": [], + "@rules_rust//rust/platform:x86_64-unknown-freebsd": [], + "@rules_rust//rust/platform:x86_64-unknown-linux-gnu": [], + "@rules_rust//rust/platform:x86_64-unknown-nixos-gnu": [], + "@rules_rust//rust/platform:x86_64-unknown-none": [], + "//conditions:default": ["@platforms//:incompatible"], + }), + version = "1.0.37", + deps = [ + "@crates_vendor__proc-macro2-1.0.89//:proc_macro2", + ], +) diff --git a/bazel/cargo/remote/BUILD.ryu-1.0.18.bazel b/bazel/cargo/remote/BUILD.ryu-1.0.18.bazel new file mode 100644 index 00000000..2a49d080 --- /dev/null +++ b/bazel/cargo/remote/BUILD.ryu-1.0.18.bazel @@ -0,0 +1,81 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "ryu", + srcs = glob( + include = ["**/*.rs"], + allow_empty = True, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=ryu", + "manual", + "noclippy", + "norustfmt", + ], + target_compatible_with = select({ + "@rules_rust//rust/platform:aarch64-apple-darwin": [], + "@rules_rust//rust/platform:aarch64-apple-ios": [], + "@rules_rust//rust/platform:aarch64-apple-ios-sim": [], + "@rules_rust//rust/platform:aarch64-fuchsia": [], + "@rules_rust//rust/platform:aarch64-linux-android": [], + "@rules_rust//rust/platform:aarch64-pc-windows-msvc": [], + "@rules_rust//rust/platform:aarch64-unknown-linux-gnu": [], + "@rules_rust//rust/platform:aarch64-unknown-nixos-gnu": [], + "@rules_rust//rust/platform:aarch64-unknown-nto-qnx710": [], + "@rules_rust//rust/platform:arm-unknown-linux-gnueabi": [], + "@rules_rust//rust/platform:armv7-linux-androideabi": [], + "@rules_rust//rust/platform:armv7-unknown-linux-gnueabi": [], + "@rules_rust//rust/platform:i686-apple-darwin": [], + "@rules_rust//rust/platform:i686-linux-android": [], + "@rules_rust//rust/platform:i686-pc-windows-msvc": [], + "@rules_rust//rust/platform:i686-unknown-freebsd": [], + "@rules_rust//rust/platform:i686-unknown-linux-gnu": [], + "@rules_rust//rust/platform:powerpc-unknown-linux-gnu": [], + "@rules_rust//rust/platform:riscv32imc-unknown-none-elf": [], + "@rules_rust//rust/platform:riscv64gc-unknown-none-elf": [], + "@rules_rust//rust/platform:s390x-unknown-linux-gnu": [], + "@rules_rust//rust/platform:thumbv7em-none-eabi": [], + "@rules_rust//rust/platform:thumbv8m.main-none-eabi": [], + "@rules_rust//rust/platform:wasm32-unknown-unknown": [], + "@rules_rust//rust/platform:wasm32-wasi": [], + "@rules_rust//rust/platform:x86_64-apple-darwin": [], + "@rules_rust//rust/platform:x86_64-apple-ios": [], + "@rules_rust//rust/platform:x86_64-fuchsia": [], + "@rules_rust//rust/platform:x86_64-linux-android": [], + "@rules_rust//rust/platform:x86_64-pc-windows-msvc": [], + "@rules_rust//rust/platform:x86_64-unknown-freebsd": [], + "@rules_rust//rust/platform:x86_64-unknown-linux-gnu": [], + "@rules_rust//rust/platform:x86_64-unknown-nixos-gnu": [], + "@rules_rust//rust/platform:x86_64-unknown-none": [], + "//conditions:default": ["@platforms//:incompatible"], + }), + version = "1.0.18", +) diff --git a/bazel/cargo/remote/BUILD.serde-1.0.214.bazel b/bazel/cargo/remote/BUILD.serde-1.0.214.bazel new file mode 100644 index 00000000..ecc2921b --- /dev/null +++ b/bazel/cargo/remote/BUILD.serde-1.0.214.bazel @@ -0,0 +1,155 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo:crates_vendor +############################################################################### + +load("@rules_rust//cargo:defs.bzl", "cargo_build_script") +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "serde", + srcs = glob( + include = ["**/*.rs"], + allow_empty = True, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "default", + "derive", + "serde_derive", + "std", + ], + crate_root = "src/lib.rs", + edition = "2018", + proc_macro_deps = [ + "@crates_vendor__serde_derive-1.0.214//:serde_derive", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=serde", + "manual", + "noclippy", + "norustfmt", + ], + target_compatible_with = select({ + "@rules_rust//rust/platform:aarch64-apple-darwin": [], + "@rules_rust//rust/platform:aarch64-apple-ios": [], + "@rules_rust//rust/platform:aarch64-apple-ios-sim": [], + "@rules_rust//rust/platform:aarch64-fuchsia": [], + "@rules_rust//rust/platform:aarch64-linux-android": [], + "@rules_rust//rust/platform:aarch64-pc-windows-msvc": [], + "@rules_rust//rust/platform:aarch64-unknown-linux-gnu": [], + "@rules_rust//rust/platform:aarch64-unknown-nixos-gnu": [], + "@rules_rust//rust/platform:aarch64-unknown-nto-qnx710": [], + "@rules_rust//rust/platform:arm-unknown-linux-gnueabi": [], + "@rules_rust//rust/platform:armv7-linux-androideabi": [], + "@rules_rust//rust/platform:armv7-unknown-linux-gnueabi": [], + "@rules_rust//rust/platform:i686-apple-darwin": [], + "@rules_rust//rust/platform:i686-linux-android": [], + "@rules_rust//rust/platform:i686-pc-windows-msvc": [], + "@rules_rust//rust/platform:i686-unknown-freebsd": [], + "@rules_rust//rust/platform:i686-unknown-linux-gnu": [], + "@rules_rust//rust/platform:powerpc-unknown-linux-gnu": [], + "@rules_rust//rust/platform:riscv32imc-unknown-none-elf": [], + "@rules_rust//rust/platform:riscv64gc-unknown-none-elf": [], + "@rules_rust//rust/platform:s390x-unknown-linux-gnu": [], + "@rules_rust//rust/platform:thumbv7em-none-eabi": [], + "@rules_rust//rust/platform:thumbv8m.main-none-eabi": [], + "@rules_rust//rust/platform:wasm32-unknown-unknown": [], + "@rules_rust//rust/platform:wasm32-wasi": [], + "@rules_rust//rust/platform:x86_64-apple-darwin": [], + "@rules_rust//rust/platform:x86_64-apple-ios": [], + "@rules_rust//rust/platform:x86_64-fuchsia": [], + "@rules_rust//rust/platform:x86_64-linux-android": [], + "@rules_rust//rust/platform:x86_64-pc-windows-msvc": [], + "@rules_rust//rust/platform:x86_64-unknown-freebsd": [], + "@rules_rust//rust/platform:x86_64-unknown-linux-gnu": [], + "@rules_rust//rust/platform:x86_64-unknown-nixos-gnu": [], + "@rules_rust//rust/platform:x86_64-unknown-none": [], + "//conditions:default": ["@platforms//:incompatible"], + }), + version = "1.0.214", + deps = [ + "@crates_vendor__serde-1.0.214//:build_script_build", + ], +) + +cargo_build_script( + name = "_bs", + srcs = glob( + include = ["**/*.rs"], + allow_empty = True, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + "**/*.rs", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "default", + "derive", + "serde_derive", + "std", + ], + crate_name = "build_script_build", + crate_root = "build.rs", + data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + edition = "2018", + pkg_name = "serde", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=serde", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.0.214", + visibility = ["//visibility:private"], +) + +alias( + name = "build_script_build", + actual = ":_bs", + tags = ["manual"], +) diff --git a/bazel/cargo/remote/BUILD.serde_derive-1.0.214.bazel b/bazel/cargo/remote/BUILD.serde_derive-1.0.214.bazel new file mode 100644 index 00000000..4c1cbddf --- /dev/null +++ b/bazel/cargo/remote/BUILD.serde_derive-1.0.214.bazel @@ -0,0 +1,89 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_proc_macro") + +package(default_visibility = ["//visibility:public"]) + +rust_proc_macro( + name = "serde_derive", + srcs = glob( + include = ["**/*.rs"], + allow_empty = True, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "default", + ], + crate_root = "src/lib.rs", + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=serde_derive", + "manual", + "noclippy", + "norustfmt", + ], + target_compatible_with = select({ + "@rules_rust//rust/platform:aarch64-apple-darwin": [], + "@rules_rust//rust/platform:aarch64-apple-ios": [], + "@rules_rust//rust/platform:aarch64-apple-ios-sim": [], + "@rules_rust//rust/platform:aarch64-fuchsia": [], + "@rules_rust//rust/platform:aarch64-linux-android": [], + "@rules_rust//rust/platform:aarch64-pc-windows-msvc": [], + "@rules_rust//rust/platform:aarch64-unknown-linux-gnu": [], + "@rules_rust//rust/platform:aarch64-unknown-nixos-gnu": [], + "@rules_rust//rust/platform:aarch64-unknown-nto-qnx710": [], + "@rules_rust//rust/platform:arm-unknown-linux-gnueabi": [], + "@rules_rust//rust/platform:armv7-linux-androideabi": [], + "@rules_rust//rust/platform:armv7-unknown-linux-gnueabi": [], + "@rules_rust//rust/platform:i686-apple-darwin": [], + "@rules_rust//rust/platform:i686-linux-android": [], + "@rules_rust//rust/platform:i686-pc-windows-msvc": [], + "@rules_rust//rust/platform:i686-unknown-freebsd": [], + "@rules_rust//rust/platform:i686-unknown-linux-gnu": [], + "@rules_rust//rust/platform:powerpc-unknown-linux-gnu": [], + "@rules_rust//rust/platform:riscv32imc-unknown-none-elf": [], + "@rules_rust//rust/platform:riscv64gc-unknown-none-elf": [], + "@rules_rust//rust/platform:s390x-unknown-linux-gnu": [], + "@rules_rust//rust/platform:thumbv7em-none-eabi": [], + "@rules_rust//rust/platform:thumbv8m.main-none-eabi": [], + "@rules_rust//rust/platform:wasm32-unknown-unknown": [], + "@rules_rust//rust/platform:wasm32-wasi": [], + "@rules_rust//rust/platform:x86_64-apple-darwin": [], + "@rules_rust//rust/platform:x86_64-apple-ios": [], + "@rules_rust//rust/platform:x86_64-fuchsia": [], + "@rules_rust//rust/platform:x86_64-linux-android": [], + "@rules_rust//rust/platform:x86_64-pc-windows-msvc": [], + "@rules_rust//rust/platform:x86_64-unknown-freebsd": [], + "@rules_rust//rust/platform:x86_64-unknown-linux-gnu": [], + "@rules_rust//rust/platform:x86_64-unknown-nixos-gnu": [], + "@rules_rust//rust/platform:x86_64-unknown-none": [], + "//conditions:default": ["@platforms//:incompatible"], + }), + version = "1.0.214", + deps = [ + "@crates_vendor__proc-macro2-1.0.89//:proc_macro2", + "@crates_vendor__quote-1.0.37//:quote", + "@crates_vendor__syn-2.0.87//:syn", + ], +) diff --git a/bazel/cargo/remote/BUILD.serde_json-1.0.132.bazel b/bazel/cargo/remote/BUILD.serde_json-1.0.132.bazel new file mode 100644 index 00000000..0bff7800 --- /dev/null +++ b/bazel/cargo/remote/BUILD.serde_json-1.0.132.bazel @@ -0,0 +1,152 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo:crates_vendor +############################################################################### + +load("@rules_rust//cargo:defs.bzl", "cargo_build_script") +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "serde_json", + srcs = glob( + include = ["**/*.rs"], + allow_empty = True, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "default", + "std", + ], + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=serde_json", + "manual", + "noclippy", + "norustfmt", + ], + target_compatible_with = select({ + "@rules_rust//rust/platform:aarch64-apple-darwin": [], + "@rules_rust//rust/platform:aarch64-apple-ios": [], + "@rules_rust//rust/platform:aarch64-apple-ios-sim": [], + "@rules_rust//rust/platform:aarch64-fuchsia": [], + "@rules_rust//rust/platform:aarch64-linux-android": [], + "@rules_rust//rust/platform:aarch64-pc-windows-msvc": [], + "@rules_rust//rust/platform:aarch64-unknown-linux-gnu": [], + "@rules_rust//rust/platform:aarch64-unknown-nixos-gnu": [], + "@rules_rust//rust/platform:aarch64-unknown-nto-qnx710": [], + "@rules_rust//rust/platform:arm-unknown-linux-gnueabi": [], + "@rules_rust//rust/platform:armv7-linux-androideabi": [], + "@rules_rust//rust/platform:armv7-unknown-linux-gnueabi": [], + "@rules_rust//rust/platform:i686-apple-darwin": [], + "@rules_rust//rust/platform:i686-linux-android": [], + "@rules_rust//rust/platform:i686-pc-windows-msvc": [], + "@rules_rust//rust/platform:i686-unknown-freebsd": [], + "@rules_rust//rust/platform:i686-unknown-linux-gnu": [], + "@rules_rust//rust/platform:powerpc-unknown-linux-gnu": [], + "@rules_rust//rust/platform:riscv32imc-unknown-none-elf": [], + "@rules_rust//rust/platform:riscv64gc-unknown-none-elf": [], + "@rules_rust//rust/platform:s390x-unknown-linux-gnu": [], + "@rules_rust//rust/platform:thumbv7em-none-eabi": [], + "@rules_rust//rust/platform:thumbv8m.main-none-eabi": [], + "@rules_rust//rust/platform:wasm32-unknown-unknown": [], + "@rules_rust//rust/platform:wasm32-wasi": [], + "@rules_rust//rust/platform:x86_64-apple-darwin": [], + "@rules_rust//rust/platform:x86_64-apple-ios": [], + "@rules_rust//rust/platform:x86_64-fuchsia": [], + "@rules_rust//rust/platform:x86_64-linux-android": [], + "@rules_rust//rust/platform:x86_64-pc-windows-msvc": [], + "@rules_rust//rust/platform:x86_64-unknown-freebsd": [], + "@rules_rust//rust/platform:x86_64-unknown-linux-gnu": [], + "@rules_rust//rust/platform:x86_64-unknown-nixos-gnu": [], + "@rules_rust//rust/platform:x86_64-unknown-none": [], + "//conditions:default": ["@platforms//:incompatible"], + }), + version = "1.0.132", + deps = [ + "@crates_vendor__itoa-1.0.11//:itoa", + "@crates_vendor__memchr-2.7.4//:memchr", + "@crates_vendor__ryu-1.0.18//:ryu", + "@crates_vendor__serde-1.0.214//:serde", + "@crates_vendor__serde_json-1.0.132//:build_script_build", + ], +) + +cargo_build_script( + name = "_bs", + srcs = glob( + include = ["**/*.rs"], + allow_empty = True, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + "**/*.rs", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "default", + "std", + ], + crate_name = "build_script_build", + crate_root = "build.rs", + data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + edition = "2021", + pkg_name = "serde_json", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=serde_json", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.0.132", + visibility = ["//visibility:private"], +) + +alias( + name = "build_script_build", + actual = ":_bs", + tags = ["manual"], +) diff --git a/bazel/cargo/remote/BUILD.syn-2.0.87.bazel b/bazel/cargo/remote/BUILD.syn-2.0.87.bazel new file mode 100644 index 00000000..ae6beb05 --- /dev/null +++ b/bazel/cargo/remote/BUILD.syn-2.0.87.bazel @@ -0,0 +1,93 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "syn", + srcs = glob( + include = ["**/*.rs"], + allow_empty = True, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "clone-impls", + "derive", + "parsing", + "printing", + "proc-macro", + ], + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=syn", + "manual", + "noclippy", + "norustfmt", + ], + target_compatible_with = select({ + "@rules_rust//rust/platform:aarch64-apple-darwin": [], + "@rules_rust//rust/platform:aarch64-apple-ios": [], + "@rules_rust//rust/platform:aarch64-apple-ios-sim": [], + "@rules_rust//rust/platform:aarch64-fuchsia": [], + "@rules_rust//rust/platform:aarch64-linux-android": [], + "@rules_rust//rust/platform:aarch64-pc-windows-msvc": [], + "@rules_rust//rust/platform:aarch64-unknown-linux-gnu": [], + "@rules_rust//rust/platform:aarch64-unknown-nixos-gnu": [], + "@rules_rust//rust/platform:aarch64-unknown-nto-qnx710": [], + "@rules_rust//rust/platform:arm-unknown-linux-gnueabi": [], + "@rules_rust//rust/platform:armv7-linux-androideabi": [], + "@rules_rust//rust/platform:armv7-unknown-linux-gnueabi": [], + "@rules_rust//rust/platform:i686-apple-darwin": [], + "@rules_rust//rust/platform:i686-linux-android": [], + "@rules_rust//rust/platform:i686-pc-windows-msvc": [], + "@rules_rust//rust/platform:i686-unknown-freebsd": [], + "@rules_rust//rust/platform:i686-unknown-linux-gnu": [], + "@rules_rust//rust/platform:powerpc-unknown-linux-gnu": [], + "@rules_rust//rust/platform:riscv32imc-unknown-none-elf": [], + "@rules_rust//rust/platform:riscv64gc-unknown-none-elf": [], + "@rules_rust//rust/platform:s390x-unknown-linux-gnu": [], + "@rules_rust//rust/platform:thumbv7em-none-eabi": [], + "@rules_rust//rust/platform:thumbv8m.main-none-eabi": [], + "@rules_rust//rust/platform:wasm32-unknown-unknown": [], + "@rules_rust//rust/platform:wasm32-wasi": [], + "@rules_rust//rust/platform:x86_64-apple-darwin": [], + "@rules_rust//rust/platform:x86_64-apple-ios": [], + "@rules_rust//rust/platform:x86_64-fuchsia": [], + "@rules_rust//rust/platform:x86_64-linux-android": [], + "@rules_rust//rust/platform:x86_64-pc-windows-msvc": [], + "@rules_rust//rust/platform:x86_64-unknown-freebsd": [], + "@rules_rust//rust/platform:x86_64-unknown-linux-gnu": [], + "@rules_rust//rust/platform:x86_64-unknown-nixos-gnu": [], + "@rules_rust//rust/platform:x86_64-unknown-none": [], + "//conditions:default": ["@platforms//:incompatible"], + }), + version = "2.0.87", + deps = [ + "@crates_vendor__proc-macro2-1.0.89//:proc_macro2", + "@crates_vendor__quote-1.0.37//:quote", + "@crates_vendor__unicode-ident-1.0.13//:unicode_ident", + ], +) diff --git a/bazel/cargo/remote/BUILD.unicode-ident-1.0.13.bazel b/bazel/cargo/remote/BUILD.unicode-ident-1.0.13.bazel new file mode 100644 index 00000000..b074d002 --- /dev/null +++ b/bazel/cargo/remote/BUILD.unicode-ident-1.0.13.bazel @@ -0,0 +1,81 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "unicode_ident", + srcs = glob( + include = ["**/*.rs"], + allow_empty = True, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=unicode-ident", + "manual", + "noclippy", + "norustfmt", + ], + target_compatible_with = select({ + "@rules_rust//rust/platform:aarch64-apple-darwin": [], + "@rules_rust//rust/platform:aarch64-apple-ios": [], + "@rules_rust//rust/platform:aarch64-apple-ios-sim": [], + "@rules_rust//rust/platform:aarch64-fuchsia": [], + "@rules_rust//rust/platform:aarch64-linux-android": [], + "@rules_rust//rust/platform:aarch64-pc-windows-msvc": [], + "@rules_rust//rust/platform:aarch64-unknown-linux-gnu": [], + "@rules_rust//rust/platform:aarch64-unknown-nixos-gnu": [], + "@rules_rust//rust/platform:aarch64-unknown-nto-qnx710": [], + "@rules_rust//rust/platform:arm-unknown-linux-gnueabi": [], + "@rules_rust//rust/platform:armv7-linux-androideabi": [], + "@rules_rust//rust/platform:armv7-unknown-linux-gnueabi": [], + "@rules_rust//rust/platform:i686-apple-darwin": [], + "@rules_rust//rust/platform:i686-linux-android": [], + "@rules_rust//rust/platform:i686-pc-windows-msvc": [], + "@rules_rust//rust/platform:i686-unknown-freebsd": [], + "@rules_rust//rust/platform:i686-unknown-linux-gnu": [], + "@rules_rust//rust/platform:powerpc-unknown-linux-gnu": [], + "@rules_rust//rust/platform:riscv32imc-unknown-none-elf": [], + "@rules_rust//rust/platform:riscv64gc-unknown-none-elf": [], + "@rules_rust//rust/platform:s390x-unknown-linux-gnu": [], + "@rules_rust//rust/platform:thumbv7em-none-eabi": [], + "@rules_rust//rust/platform:thumbv8m.main-none-eabi": [], + "@rules_rust//rust/platform:wasm32-unknown-unknown": [], + "@rules_rust//rust/platform:wasm32-wasi": [], + "@rules_rust//rust/platform:x86_64-apple-darwin": [], + "@rules_rust//rust/platform:x86_64-apple-ios": [], + "@rules_rust//rust/platform:x86_64-fuchsia": [], + "@rules_rust//rust/platform:x86_64-linux-android": [], + "@rules_rust//rust/platform:x86_64-pc-windows-msvc": [], + "@rules_rust//rust/platform:x86_64-unknown-freebsd": [], + "@rules_rust//rust/platform:x86_64-unknown-linux-gnu": [], + "@rules_rust//rust/platform:x86_64-unknown-nixos-gnu": [], + "@rules_rust//rust/platform:x86_64-unknown-none": [], + "//conditions:default": ["@platforms//:incompatible"], + }), + version = "1.0.13", +) diff --git a/bazel/cargo/remote/defs.bzl b/bazel/cargo/remote/defs.bzl index e4051261..fcd06caa 100644 --- a/bazel/cargo/remote/defs.bzl +++ b/bazel/cargo/remote/defs.bzl @@ -310,11 +310,17 @@ _NORMAL_ALIASES = { _NORMAL_DEV_DEPENDENCIES = { "": { + _COMMON_CONDITION: { + "serde": Label("@crates_vendor__serde-1.0.214//:serde"), + "serde_json": Label("@crates_vendor__serde_json-1.0.132//:serde_json"), + }, }, } _NORMAL_DEV_ALIASES = { "": { + _COMMON_CONDITION: { + }, }, } @@ -335,6 +341,8 @@ _PROC_MACRO_DEV_DEPENDENCIES = { _PROC_MACRO_DEV_ALIASES = { "": { + _COMMON_CONDITION: { + }, }, } @@ -443,6 +451,16 @@ def crate_repositories(): build_file = Label("@proxy_wasm_rust_sdk//bazel/cargo/remote:BUILD.hashbrown-0.15.0.bazel"), ) + maybe( + http_archive, + name = "crates_vendor__itoa-1.0.11", + sha256 = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b", + type = "tar.gz", + urls = ["https://static.crates.io/crates/itoa/1.0.11/download"], + strip_prefix = "itoa-1.0.11", + build_file = Label("@proxy_wasm_rust_sdk//bazel/cargo/remote:BUILD.itoa-1.0.11.bazel"), + ) + maybe( http_archive, name = "crates_vendor__log-0.4.22", @@ -453,7 +471,99 @@ def crate_repositories(): build_file = Label("@proxy_wasm_rust_sdk//bazel/cargo/remote:BUILD.log-0.4.22.bazel"), ) + maybe( + http_archive, + name = "crates_vendor__memchr-2.7.4", + sha256 = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3", + type = "tar.gz", + urls = ["https://static.crates.io/crates/memchr/2.7.4/download"], + strip_prefix = "memchr-2.7.4", + build_file = Label("@proxy_wasm_rust_sdk//bazel/cargo/remote:BUILD.memchr-2.7.4.bazel"), + ) + + maybe( + http_archive, + name = "crates_vendor__proc-macro2-1.0.89", + sha256 = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e", + type = "tar.gz", + urls = ["https://static.crates.io/crates/proc-macro2/1.0.89/download"], + strip_prefix = "proc-macro2-1.0.89", + build_file = Label("@proxy_wasm_rust_sdk//bazel/cargo/remote:BUILD.proc-macro2-1.0.89.bazel"), + ) + + maybe( + http_archive, + name = "crates_vendor__quote-1.0.37", + sha256 = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af", + type = "tar.gz", + urls = ["https://static.crates.io/crates/quote/1.0.37/download"], + strip_prefix = "quote-1.0.37", + build_file = Label("@proxy_wasm_rust_sdk//bazel/cargo/remote:BUILD.quote-1.0.37.bazel"), + ) + + maybe( + http_archive, + name = "crates_vendor__ryu-1.0.18", + sha256 = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f", + type = "tar.gz", + urls = ["https://static.crates.io/crates/ryu/1.0.18/download"], + strip_prefix = "ryu-1.0.18", + build_file = Label("@proxy_wasm_rust_sdk//bazel/cargo/remote:BUILD.ryu-1.0.18.bazel"), + ) + + maybe( + http_archive, + name = "crates_vendor__serde-1.0.214", + sha256 = "f55c3193aca71c12ad7890f1785d2b73e1b9f63a0bbc353c08ef26fe03fc56b5", + type = "tar.gz", + urls = ["https://static.crates.io/crates/serde/1.0.214/download"], + strip_prefix = "serde-1.0.214", + build_file = Label("@proxy_wasm_rust_sdk//bazel/cargo/remote:BUILD.serde-1.0.214.bazel"), + ) + + maybe( + http_archive, + name = "crates_vendor__serde_derive-1.0.214", + sha256 = "de523f781f095e28fa605cdce0f8307e451cc0fd14e2eb4cd2e98a355b147766", + type = "tar.gz", + urls = ["https://static.crates.io/crates/serde_derive/1.0.214/download"], + strip_prefix = "serde_derive-1.0.214", + build_file = Label("@proxy_wasm_rust_sdk//bazel/cargo/remote:BUILD.serde_derive-1.0.214.bazel"), + ) + + maybe( + http_archive, + name = "crates_vendor__serde_json-1.0.132", + sha256 = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03", + type = "tar.gz", + urls = ["https://static.crates.io/crates/serde_json/1.0.132/download"], + strip_prefix = "serde_json-1.0.132", + build_file = Label("@proxy_wasm_rust_sdk//bazel/cargo/remote:BUILD.serde_json-1.0.132.bazel"), + ) + + maybe( + http_archive, + name = "crates_vendor__syn-2.0.87", + sha256 = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d", + type = "tar.gz", + urls = ["https://static.crates.io/crates/syn/2.0.87/download"], + strip_prefix = "syn-2.0.87", + build_file = Label("@proxy_wasm_rust_sdk//bazel/cargo/remote:BUILD.syn-2.0.87.bazel"), + ) + + maybe( + http_archive, + name = "crates_vendor__unicode-ident-1.0.13", + sha256 = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe", + type = "tar.gz", + urls = ["https://static.crates.io/crates/unicode-ident/1.0.13/download"], + strip_prefix = "unicode-ident-1.0.13", + build_file = Label("@proxy_wasm_rust_sdk//bazel/cargo/remote:BUILD.unicode-ident-1.0.13.bazel"), + ) + return [ struct(repo = "crates_vendor__hashbrown-0.15.0", is_dev_dep = False), struct(repo = "crates_vendor__log-0.4.22", is_dev_dep = False), + struct(repo = "crates_vendor__serde-1.0.214", is_dev_dep = True), + struct(repo = "crates_vendor__serde_json-1.0.132", is_dev_dep = True), ] diff --git a/src/traits.rs b/src/traits.rs index bd54bcbe..b134baf1 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -58,6 +58,70 @@ pub trait Context { hostcalls::enqueue_shared_queue(queue_id, value) } + /// Sends HTTP request with serialized `headers`, `body`, and serialized `trailers` to upstream. + /// + /// `on_http_call_response()` will be called with `token_id` when the response is received by the host, or after the timeout. + /// + /// # Arguments + /// + /// * `upstream` - The name of the upstream to send the request to (in your envoy configuration) + /// * `headers` - The headers to send with the request (in the form of `Vec<(&str, &str)>`) + /// * `body` - The body of the request (in the form of `Option<&[u8]>` - `None` if no body) + /// * `trailers` - The trailers to send with the request (in the form of `Vec<(&str, &str)>`) + /// * `timeout` - The timeout for the request + /// + /// # Returns + /// + /// A Result containing either + /// + /// * `Ok(token_id)` - The token id of the request + /// * `Err(Status)` - An error status + /// + /// # Example + /// + /// ```rust + /// use proxy_wasm::traits::*; + /// use proxy_wasm::types::*; + /// use std::time::Duration; + /// use log::{debug, warn}; + /// + /// struct MyPlugin; + /// + /// impl HttpContext for MyPlugin { + /// fn on_http_request_headers(&mut self, _num_headers: usize, _end_of_stream: bool) -> Action { + /// match self.dispatch_http_call( + /// "google", + /// vec![ + /// (":method", "GET"), + /// (":path", "/"), + /// (":authority", "google.com")], + /// None, + /// vec![], + /// Duration::from_secs(5), + /// ) { + /// Ok(_) => Action::Pause, + /// Err(e) => { + /// warn!("Failed to dispatch_http_call: {:?}", e); + /// Action::Pause + /// } + /// } + /// } + /// } + /// + /// impl Context for MyPlugin { + /// fn on_http_call_response(&mut self, _token_id: u32, _: usize, body_size: usize, _: usize) { + /// let headers = self.get_http_call_response_headers(); + /// let body = self.get_http_call_response_body(0, body_size).unwrap(); + /// let body_str = String::from_utf8(body).unwrap(); + /// + /// debug!("Received response headers: {:?}", headers); + /// debug!("Received response body: {:?}", body_str); + /// + /// // Resume the HTTP request after processing the response + /// self.resume_http_request(); + /// } + /// } + /// ``` fn dispatch_http_call( &self, upstream: &str, @@ -69,6 +133,66 @@ pub trait Context { hostcalls::dispatch_http_call(upstream, headers, body, trailers, timeout) } + /// Called when HTTP response using `dispatch_http_call` is received. + /// + /// If `num_headers` is 0, then the HTTP call failed. + /// + /// All headers can be retrieved using `self.get_http_call_response_headers()` or individually `self.get_http_call_response_header(name)`. + /// + /// All trailers can be retrieved using `self.get_http_call_response_trailers()` or individually `self.get_http_call_response_trailer(name)`. + /// + /// # Arguments + /// + /// * `token_id` - The token id of the call + /// * `num_headers` - The number of headers in the response + /// * `body_size` - The size of the body in the response + /// * `num_trailers` - The number of trailers in the response + /// + /// # Example + /// + /// ```rust + /// use proxy_wasm::traits::*; + /// use proxy_wasm::types::*; + /// use std::time::Duration; + /// use log::{debug, warn}; + /// + /// struct MyPlugin; + /// + /// impl HttpContext for MyPlugin { + /// fn on_http_request_headers(&mut self, _num_headers: usize, _end_of_stream: bool) -> Action { + /// match self.dispatch_http_call( + /// "google", + /// vec![ + /// (":method", "GET"), + /// (":path", "/"), + /// (":authority", "google.com")], + /// None, + /// vec![], + /// Duration::from_secs(5), + /// ) { + /// Ok(_) => Action::Pause, + /// Err(e) => { + /// warn!("Failed to dispatch_http_call: {:?}", e); + /// Action::Pause + /// } + /// } + /// } + /// } + /// + /// impl Context for MyPlugin { + /// fn on_http_call_response(&mut self, _token_id: u32, _: usize, body_size: usize, _: usize) { + /// let headers = self.get_http_call_response_headers(); + /// let body = self.get_http_call_response_body(0, body_size).unwrap(); + /// let body_str = String::from_utf8(body).unwrap(); + /// + /// debug!("Received response headers: {:?}", headers); + /// debug!("Received response body: {:?}", body_str); + /// + /// // Resume the HTTP request after processing the response + /// self.resume_http_request(); + /// } + /// } + /// ``` fn on_http_call_response( &mut self, _token_id: u32, @@ -78,38 +202,491 @@ pub trait Context { ) { } + /// Get the HTTP call response headers. + /// + /// # Returns + /// + /// * `Vec<(String, String)>` - the HTTP call response headers + /// + /// # Example + /// + /// ```rust + /// use proxy_wasm::traits::*; + /// use proxy_wasm::types::*; + /// use std::time::Duration; + /// use log::{debug, warn}; + /// + /// struct MyPlugin; + /// + /// impl HttpContext for MyPlugin { + /// fn on_http_request_headers(&mut self, _num_headers: usize, _end_of_stream: bool) -> Action { + /// match self.dispatch_http_call( + /// "google", + /// vec![ + /// (":method", "GET"), + /// (":path", "/"), + /// (":authority", "google.com")], + /// None, + /// vec![], + /// Duration::from_secs(5), + /// ) { + /// Ok(_) => Action::Pause, + /// Err(e) => { + /// warn!("Failed to dispatch_http_call: {:?}", e); + /// Action::Pause + /// } + /// } + /// } + /// } + /// + /// impl Context for MyPlugin { + /// fn on_http_call_response(&mut self, _token_id: u32, _: usize, body_size: usize, _: usize) { + /// let headers = self.get_http_call_response_headers(); + /// + /// debug!("Received response headers: {:?}", headers); + /// + /// // Resume the HTTP request after processing the response + /// self.resume_http_request(); + /// } + /// } + /// ``` fn get_http_call_response_headers(&self) -> Vec<(String, String)> { hostcalls::get_map(MapType::HttpCallResponseHeaders).unwrap() } + /// Get all HTTP call response headers as bytes. + /// + /// # Returns + /// + /// * `Vec<(String, Bytes)>` - a list of HTTP call response headers + /// + /// # Example + /// + /// ```rust + /// use proxy_wasm::traits::*; + /// use proxy_wasm::types::*; + /// use std::time::Duration; + /// use log::{debug, warn}; + /// + /// struct MyPlugin; + /// + /// impl HttpContext for MyPlugin { + /// fn on_http_request_headers(&mut self, _num_headers: usize, _end_of_stream: bool) -> Action { + /// match self.dispatch_http_call( + /// "google", + /// vec![ + /// (":method", "GET"), + /// (":path", "/"), + /// (":authority", "google.com")], + /// None, + /// vec![], + /// Duration::from_secs(5), + /// ) { + /// Ok(_) => Action::Pause, + /// Err(e) => { + /// warn!("Failed to dispatch_http_call: {:?}", e); + /// Action::Pause + /// } + /// } + /// } + /// } + /// + /// impl Context for MyPlugin { + /// fn on_http_call_response(&mut self, _token_id: u32, _: usize, body_size: usize, _: usize) { + /// let headers = self.get_http_call_response_headers_bytes(); + /// + /// for (name, value) in headers { + /// let value_str = String::from_utf8(value).unwrap(); + /// debug!("Received response header: {:?} = {:?}", name, value_str); + /// + /// // Resume the HTTP call after processing the response + /// self.resume_http_request(); + /// } + /// } + /// } + /// ``` fn get_http_call_response_headers_bytes(&self) -> Vec<(String, Bytes)> { hostcalls::get_map_bytes(MapType::HttpCallResponseHeaders).unwrap() } + /// Get a HTTP call response header by name. + /// + /// # Arguments + /// + /// * `name` - the name of the header + /// + /// # Returns + /// + /// * `Option` - the HTTP call response header or `None` if the header is not found + /// + /// # Example + /// + /// ```rust + /// use proxy_wasm::traits::*; + /// use proxy_wasm::types::*; + /// use std::time::Duration; + /// use log::{debug, warn}; + /// + /// struct MyPlugin; + /// + /// impl HttpContext for MyPlugin { + /// fn on_http_request_headers(&mut self, _num_headers: usize, _end_of_stream: bool) -> Action { + /// match self.dispatch_http_call( + /// "google", + /// vec![ + /// (":method", "GET"), + /// (":path", "/"), + /// (":authority", "google.com")], + /// None, + /// vec![], + /// Duration::from_secs(5), + /// ) { + /// Ok(_) => Action::Pause, + /// Err(e) => { + /// warn!("Failed to dispatch_http_call: {:?}", e); + /// Action::Pause + /// } + /// } + /// } + /// } + /// + /// impl Context for MyPlugin { + /// fn on_http_call_response(&mut self, _token_id: u32, _: usize, body_size: usize, _: usize) { + /// let content_type = self.get_http_call_response_header("content-type"); + /// debug!("Content-Type: {:?}", content_type); + /// + /// // Resume the HTTP request after processing the response + /// self.resume_http_request(); + /// } + /// } + /// ``` fn get_http_call_response_header(&self, name: &str) -> Option { hostcalls::get_map_value(MapType::HttpCallResponseHeaders, name).unwrap() } + /// Get a HTTP call response header by name as bytes. + /// + /// # Arguments + /// + /// * `name` - the name of the header + /// + /// # Returns + /// + /// * `Option` - the HTTP call response header or `None` if the header is not found + /// + /// # Example + /// + /// ```rust + /// use proxy_wasm::traits::*; + /// use proxy_wasm::types::*; + /// use std::time::Duration; + /// use log::{debug, warn}; + /// + /// struct MyPlugin; + /// + /// impl HttpContext for MyPlugin { + /// fn on_http_request_headers(&mut self, _num_headers: usize, _end_of_stream: bool) -> Action { + /// match self.dispatch_http_call( + /// "google", + /// vec![ + /// (":method", "GET"), + /// (":path", "/"), + /// (":authority", "google.com")], + /// None, + /// vec![], + /// Duration::from_secs(5), + /// ) { + /// Ok(_) => Action::Pause, + /// Err(e) => { + /// warn!("Failed to dispatch_http_call: {:?}", e); + /// Action::Pause + /// } + /// } + /// } + /// } + /// + /// impl Context for MyPlugin { + /// fn on_http_call_response(&mut self, _token_id: u32, _: usize, body_size: usize, _: usize) { + /// let content_type = self.get_http_call_response_header_bytes("content-type").unwrap(); + /// let content_type_str = String::from_utf8(content_type).unwrap(); + /// debug!("Content-Type: {:?}", content_type_str); + /// + /// // Resume the HTTP request after processing the response + /// self.resume_http_request(); + /// } + /// } + /// ``` fn get_http_call_response_header_bytes(&self, name: &str) -> Option { hostcalls::get_map_value_bytes(MapType::HttpCallResponseHeaders, name).unwrap() } + /// Get the HTTP call response body. + /// + /// # Arguments + /// + /// * `start` - the start offset of the body + /// * `max_size` - the maximum size of the body + /// + /// # Returns + /// + /// * `Option` - the HTTP call response body or `None` if the body is not found + /// + /// # Example + /// + /// ```rust + /// use proxy_wasm::traits::*; + /// use proxy_wasm::types::*; + /// use std::time::Duration; + /// use log::{debug, warn}; + /// + /// struct MyPlugin; + /// + /// impl HttpContext for MyPlugin { + /// fn on_http_request_headers(&mut self, _num_headers: usize, _end_of_stream: bool) -> Action { + /// match self.dispatch_http_call( + /// "google", + /// vec![ + /// (":method", "GET"), + /// (":path", "/"), + /// (":authority", "google.com")], + /// None, + /// vec![], + /// Duration::from_secs(5), + /// ) { + /// Ok(_) => Action::Pause, + /// Err(e) => { + /// warn!("Failed to dispatch_http_call: {:?}", e); + /// Action::Pause + /// } + /// } + /// } + /// } + /// + /// impl Context for MyPlugin { + /// fn on_http_call_response(&mut self, _token_id: u32, _: usize, body_size: usize, _: usize) { + /// let body = self.get_http_call_response_body(0, body_size).unwrap(); + /// let body_str = String::from_utf8(body).unwrap(); + /// + /// debug!("Received response body: {:?}", body_str); + /// + /// // Resume the HTTP request after processing the response + /// self.resume_http_request(); + /// } + /// } + /// ``` fn get_http_call_response_body(&self, start: usize, max_size: usize) -> Option { hostcalls::get_buffer(BufferType::HttpCallResponseBody, start, max_size).unwrap() } + /// Get the HTTP call response trailers. + /// + /// # Returns + /// + /// * `Vec<(String, String)>` - the HTTP call response trailers + /// + /// # Example + /// + /// ```rust + /// use proxy_wasm::traits::*; + /// use proxy_wasm::types::*; + /// use std::time::Duration; + /// use log::{debug, warn}; + /// + /// struct MyPlugin; + /// + /// impl HttpContext for MyPlugin { + /// fn on_http_request_headers(&mut self, _num_headers: usize, _end_of_stream: bool) -> Action { + /// match self.dispatch_http_call( + /// "google", + /// vec![ + /// (":method", "GET"), + /// (":path", "/"), + /// (":authority", "google.com")], + /// None, + /// vec![], + /// Duration::from_secs(5), + /// ) { + /// Ok(_) => Action::Pause, + /// Err(e) => { + /// warn!("Failed to dispatch_http_call: {:?}", e); + /// Action::Pause + /// } + /// } + /// } + /// } + /// + /// impl Context for MyPlugin { + /// fn on_http_call_response(&mut self, _token_id: u32, _: usize, body_size: usize, _: usize) { + /// let trailers = self.get_http_call_response_trailers(); + /// debug!("Received response trailers: {:?}", trailers); + /// + /// // Resume the HTTP call after processing the response + /// self.resume_http_request(); + /// } + /// } + /// ``` fn get_http_call_response_trailers(&self) -> Vec<(String, String)> { hostcalls::get_map(MapType::HttpCallResponseTrailers).unwrap() } + /// Get the HTTP call response trailers as bytes. + /// + /// # Returns + /// + /// * `Vec<(String, Bytes)>` - the HTTP call response trailers + /// + /// # Example + /// + /// ```rust + /// use proxy_wasm::traits::*; + /// use proxy_wasm::types::*; + /// use std::time::Duration; + /// use log::{debug, warn}; + /// + /// struct MyPlugin; + /// + /// impl HttpContext for MyPlugin { + /// fn on_http_request_headers(&mut self, _num_headers: usize, _end_of_stream: bool) -> Action { + /// match self.dispatch_http_call( + /// "google", + /// vec![ + /// (":method", "GET"), + /// (":path", "/"), + /// (":authority", "google.com")], + /// None, + /// vec![], + /// Duration::from_secs(5), + /// ) { + /// Ok(_) => Action::Pause, + /// Err(e) => { + /// warn!("Failed to dispatch_http_call: {:?}", e); + /// Action::Pause + /// } + /// } + /// } + /// } + /// + /// impl Context for MyPlugin { + /// fn on_http_call_response(&mut self, _token_id: u32, _: usize, body_size: usize, _: usize) { + /// let trailers = self.get_http_call_response_trailers_bytes(); + /// debug!("Received response trailers: {:?}", trailers); + /// + /// // Resume the HTTP call after processing the response + /// self.resume_http_request(); + /// } + /// } + /// ``` fn get_http_call_response_trailers_bytes(&self) -> Vec<(String, Bytes)> { hostcalls::get_map_bytes(MapType::HttpCallResponseTrailers).unwrap() } + /// Get a HTTP call response trailer by name. + /// + /// # Arguments + /// + /// * `name` - the name of the trailer + /// + /// # Returns + /// + /// * `Option` - the HTTP call response trailer or `None` if the trailer is not found + /// + /// # Example + /// + /// ```rust + /// use proxy_wasm::traits::*; + /// use proxy_wasm::types::*; + /// use std::time::Duration; + /// use log::{debug, warn}; + /// + /// struct MyPlugin; + /// + /// impl HttpContext for MyPlugin { + /// fn on_http_request_headers(&mut self, _num_headers: usize, _end_of_stream: bool) -> Action { + /// match self.dispatch_http_call( + /// "google", + /// vec![ + /// (":method", "GET"), + /// (":path", "/"), + /// (":authority", "google.com")], + /// None, + /// vec![], + /// Duration::from_secs(5), + /// ) { + /// Ok(_) => Action::Pause, + /// Err(e) => { + /// warn!("Failed to dispatch_http_call: {:?}", e); + /// Action::Pause + /// } + /// } + /// } + /// } + /// + /// impl Context for MyPlugin { + /// fn on_http_call_response(&mut self, _token_id: u32, _: usize, body_size: usize, _: usize) { + /// let content_type = self.get_http_call_response_trailer("content-type").unwrap(); + /// debug!("Content-Type: {:?}", content_type); + /// + /// // Resume the HTTP call after processing the response + /// self.resume_http_request(); + /// } + /// } + /// ``` fn get_http_call_response_trailer(&self, name: &str) -> Option { hostcalls::get_map_value(MapType::HttpCallResponseTrailers, name).unwrap() } + /// Get a HTTP call response trailer by name as bytes. + /// + /// # Arguments + /// + /// * `name` - the name of the trailer + /// + /// # Returns + /// + /// * `Option` - the HTTP call response trailer or `None` if the trailer is not found + /// + /// # Example + /// + /// ```rust + /// use proxy_wasm::traits::*; + /// use proxy_wasm::types::*; + /// use std::time::Duration; + /// use log::{debug, warn}; + /// + /// struct MyPlugin; + /// + /// impl HttpContext for MyPlugin { + /// fn on_http_request_headers(&mut self, _num_headers: usize, _end_of_stream: bool) -> Action { + /// match self.dispatch_http_call( + /// "google", + /// vec![ + /// (":method", "GET"), + /// (":path", "/"), + /// (":authority", "google.com")], + /// None, + /// vec![], + /// Duration::from_secs(5), + /// ) { + /// Ok(_) => Action::Pause, + /// Err(e) => { + /// warn!("Failed to dispatch_http_call: {:?}", e); + /// Action::Pause + /// } + /// } + /// } + /// } + /// + /// impl Context for MyPlugin { + /// fn on_http_call_response(&mut self, _token_id: u32, _: usize, body_size: usize, _: usize) { + /// let content_type = self.get_http_call_response_trailer_bytes("content-type").unwrap(); + /// let content_type_str = String::from_utf8(content_type).unwrap(); + /// debug!("Content-Type: {:?}", content_type_str); + /// + /// // Resume the HTTP call after processing the response + /// self.resume_http_request(); + /// } + /// } + /// ``` fn get_http_call_response_trailer_bytes(&self, name: &str) -> Option { hostcalls::get_map_value_bytes(MapType::HttpCallResponseTrailers, name).unwrap() } @@ -215,26 +792,245 @@ pub trait Context { } pub trait RootContext: Context { + /// Called when the host starts the WebAssembly Virtual Machine. + /// + /// Its configuration (of `_vm_configuration_size`) can be retrieved using `self.get_vm_configuration()`. + /// + /// # Arguments + /// + /// * `vm_configuration_size` - the size of the VM configuration + /// + /// # Returns + /// + /// * `bool` - `true` if the configuration was processed successfully, `false` otherwise + /// + /// # Example + /// + /// ```rust + /// use proxy_wasm::traits::*; + /// use proxy_wasm::types::*; + /// use log::debug; + /// + /// struct MyRootContext; + /// + /// #[derive(serde::Deserialize, Debug)] + /// struct MyVmConfiguration { + /// /// Some key + /// pub key: String, + /// } + /// + /// impl RootContext for MyRootContext { + /// fn on_vm_start(&mut self, _vm_configuration_size: usize) -> bool { + /// let vm_configuration = self.get_vm_configuration().unwrap(); + /// + /// let parsed_vm_configuration: MyVmConfiguration = + /// serde_json::from_slice::(&vm_configuration).unwrap(); + /// + /// // Do something with the parsed vm configuration + /// debug!("vm_configuration: {:?}", parsed_vm_configuration); + /// + /// true + /// } + /// } + /// + /// # impl Context for MyRootContext {} + /// ``` fn on_vm_start(&mut self, _vm_configuration_size: usize) -> bool { true } + /// Get the VM configuration. + /// + /// # Returns + /// + /// * `Option` - the VM configuration + /// + /// # Example + /// + /// ```rust + /// use proxy_wasm::traits::*; + /// use proxy_wasm::types::*; + /// use log::debug; + /// + /// struct MyRootContext; + /// + /// #[derive(serde::Deserialize, Debug)] + /// struct MyVmConfiguration { + /// /// Some key + /// pub key: String, + /// } + /// + /// impl RootContext for MyRootContext { + /// fn on_vm_start(&mut self, _vm_configuration_size: usize) -> bool { + /// let vm_configuration = self.get_vm_configuration().unwrap(); + /// + /// let parsed_vm_configuration: MyVmConfiguration = + /// serde_json::from_slice::(&vm_configuration).unwrap(); + /// + /// // Do something with the parsed vm configuration + /// debug!("vm_configuration: {:?}", parsed_vm_configuration); + /// + /// true + /// } + /// } + /// + /// # impl Context for MyRootContext {} + /// ``` fn get_vm_configuration(&self) -> Option { hostcalls::get_buffer(BufferType::VmConfiguration, 0, usize::MAX).unwrap() } + /// Called when the host starts the Proxy-Wasm plugin. + /// + /// Its configuration (of `_plugin_configuration_size`) can be retrieved using `self.get_plugin_configuration()`. + /// + /// # Returns + /// + /// Plugin must return one of the following values: + /// + /// * `true` - to indicate that the configuration was processed successfully. + /// * `false` - to indicate that the configuration processing failed. + /// + /// # Example + /// + /// ```rust + /// use proxy_wasm::traits::*; + /// use proxy_wasm::types::*; + /// use log::debug; + /// + /// struct MyRootContext; + /// + /// #[derive(serde::Deserialize, Debug)] + /// struct MyPluginConfiguration { + /// /// Some key + /// pub key: String, + /// } + /// + /// impl RootContext for MyRootContext { + /// fn on_configure(&mut self, _plugin_configuration_size: usize) -> bool { + /// let plugin_configuration = self.get_plugin_configuration().unwrap(); + /// + /// let parsed_plugin_configuration: MyPluginConfiguration = + /// serde_json::from_slice::(&plugin_configuration).unwrap(); + /// + /// // Do something with the parsed plugin configuration + /// debug!("plugin_configuration: {:?}", parsed_plugin_configuration); + /// + /// true + /// } + /// } + /// + /// # impl Context for MyRootContext {} + /// ``` fn on_configure(&mut self, _plugin_configuration_size: usize) -> bool { true } + /// Get the plugin configuration. + /// + /// # Returns + /// + /// * `Option` - the plugin configuration + /// + /// # Example + /// + /// ```rust + /// use proxy_wasm::traits::*; + /// use proxy_wasm::types::*; + /// use log::debug; + /// + /// struct MyRootContext; + /// + /// #[derive(serde::Deserialize, Debug)] + /// struct MyPluginConfiguration { + /// /// Some key + /// pub key: String, + /// } + /// + /// impl RootContext for MyRootContext { + /// fn on_configure(&mut self, _plugin_configuration_size: usize) -> bool { + /// let plugin_configuration = self.get_plugin_configuration().unwrap(); + /// + /// let parsed_plugin_configuration: MyPluginConfiguration = + /// serde_json::from_slice::(&plugin_configuration).unwrap(); + /// + /// // Do something with the parsed plugin configuration + /// debug!("plugin_configuration: {:?}", parsed_plugin_configuration); + /// + /// true + /// } + /// } + /// + /// # impl Context for MyRootContext {} + /// ``` fn get_plugin_configuration(&self) -> Option { hostcalls::get_buffer(BufferType::PluginConfiguration, 0, usize::MAX).unwrap() } + /// Sets timer period. When set, `on_tick` will be called every `tick_period`. This is useful for making periodic updates to cached data, etc. + /// + /// # Arguments + /// + /// * `period` - the period of the timer + /// + /// # Example + /// + /// ```rust + /// use proxy_wasm::traits::*; + /// use proxy_wasm::types::*; + /// use std::time::Duration; + /// use log::info; + /// + /// struct MyRootContext; + /// + /// impl RootContext for MyRootContext { + /// fn on_vm_start(&mut self, _vm_configuration_size: usize) -> bool { + /// self.set_tick_period(Duration::from_millis(5000)); + /// + /// true + /// } + /// + /// fn on_tick(&mut self) { + /// // Do something every 5 seconds + /// info!("tick!") + /// } + /// } + /// + /// # impl Context for MyRootContext {} + /// ``` fn set_tick_period(&self, period: Duration) { hostcalls::set_tick_period(period).unwrap() } + /// Called on a timer every tick period. + /// + /// The tick period can be configured using `self.set_tick_period()`. + /// + /// # Example + /// + /// ```rust + /// use proxy_wasm::traits::*; + /// use proxy_wasm::types::*; + /// use std::time::Duration; + /// use log::info; + /// + /// struct MyRootContext; + /// + /// impl RootContext for MyRootContext { + /// fn on_vm_start(&mut self, _vm_configuration_size: usize) -> bool { + /// self.set_tick_period(Duration::from_millis(5000)); + /// + /// true + /// } + /// + /// fn on_tick(&mut self) { + /// // Do something every 5 seconds + /// info!("tick!") + /// } + /// } + /// + /// # impl Context for MyRootContext {} + /// ``` fn on_tick(&mut self) {} fn on_queue_ready(&mut self, _queue_id: u32) {} @@ -307,14 +1103,120 @@ pub trait StreamContext: Context { } pub trait HttpContext: Context { + /// Called when HTTP request headers are received from downstream. + /// + /// All `num_headers` headers can be retrieved and/or modified using `self.get_http_request_headers()`. + /// + /// Individual HTTP request headers can be retrieved and/or modified using `self.get_http_request_header()`, `self.add_http_request_header()`. + /// + /// Paused request can be resumed using `self.resume_http_request()` or closed using `self.reset_http_request()`. + /// + /// Additionally, instead of forwarding requests upstream, a HTTP response can be sent using `self.send_http_response()`. + /// + /// # Arguments + /// + /// * `num_headers` - the number of HTTP request headers + /// * `end_of_stream` - indicates if this is the last call for the request headers + /// + /// # Returns + /// + /// Plugin must return one of the following values: + /// + /// * `CONTINUE` to forward `HTTP_REQUEST_HEADERS` fields downstream. + /// * `PAUSE` to pause processing. + /// + /// # Example + /// + /// ```rust + /// use proxy_wasm::traits::*; + /// use proxy_wasm::types::*; + /// use log::debug; + /// + /// struct MyPlugin; + /// + /// impl HttpContext for MyPlugin { + /// fn on_http_request_headers(&mut self, num_headers: usize, end_of_stream: bool) -> Action { + /// let headers = self.get_http_request_headers(); + /// + /// debug!("Received request headers: {:?}", headers); + /// + /// // Process the request + /// + /// Action::Continue + /// } + /// } + /// + /// # impl Context for MyPlugin {} + /// ``` fn on_http_request_headers(&mut self, _num_headers: usize, _end_of_stream: bool) -> Action { Action::Continue } + /// Get all HTTP request headers. + /// + /// # Returns + /// + /// * `Vec<(String, String)>` - a list of HTTP request headers + /// + /// # Example + /// + /// ```rust + /// use proxy_wasm::traits::*; + /// use proxy_wasm::types::*; + /// use log::debug; + /// + /// struct MyPlugin; + /// + /// impl HttpContext for MyPlugin { + /// fn on_http_request_headers(&mut self, num_headers: usize, end_of_stream: bool) -> Action { + /// let headers = self.get_http_request_headers(); + /// + /// debug!("Received request headers: {:?}", headers); + /// + /// // Process the request + /// + /// Action::Continue + /// } + /// } + /// + /// # impl Context for MyPlugin {} + /// ``` fn get_http_request_headers(&self) -> Vec<(String, String)> { hostcalls::get_map(MapType::HttpRequestHeaders).unwrap() } + /// Get all HTTP request headers as bytes. + /// + /// # Returns + /// + /// * `Vec<(String, Bytes)>` - a list of HTTP request headers + /// + /// # Example + /// + /// ```rust + /// use proxy_wasm::traits::*; + /// use proxy_wasm::types::*; + /// use log::debug; + /// + /// struct MyPlugin; + /// + /// impl HttpContext for MyPlugin { + /// fn on_http_request_headers(&mut self, num_headers: usize, end_of_stream: bool) -> Action { + /// let headers = self.get_http_request_headers_bytes(); + /// + /// for (name, value) in headers { + /// let value_str = String::from_utf8(value).unwrap(); + /// debug!("Received request header: {:?} = {:?}", name, value_str); + /// } + /// + /// // Process the request + /// + /// Action::Continue + /// } + /// } + /// + /// # impl Context for MyPlugin {} + /// ``` fn get_http_request_headers_bytes(&self) -> Vec<(String, Bytes)> { hostcalls::get_map_bytes(MapType::HttpRequestHeaders).unwrap() } @@ -327,10 +1229,74 @@ pub trait HttpContext: Context { hostcalls::set_map_bytes(MapType::HttpRequestHeaders, headers).unwrap() } + /// Get a specific HTTP request header by name. + /// + /// # Arguments + /// + /// * `name` - the name of the header + /// + /// # Returns + /// + /// * `Option` - the value of the header (wrapped in an Option) or `None` if the header does not exist + /// + /// # Example + /// + /// ```rust + /// use proxy_wasm::traits::*; + /// use proxy_wasm::types::*; + /// use log::debug; + /// + /// struct MyPlugin; + /// + /// impl HttpContext for MyPlugin { + /// fn on_http_request_headers(&mut self, _num_headers: usize, _end_of_stream: bool) -> Action { + /// let header = self.get_http_request_header(":path"); + /// + /// match header { + /// Some(value) => debug!("The path is: {}", value), + /// None => debug!("The path is missing") + /// } + /// Action::Continue + /// } + /// } + /// + /// # impl Context for MyPlugin {} + /// ``` fn get_http_request_header(&self, name: &str) -> Option { hostcalls::get_map_value(MapType::HttpRequestHeaders, name).unwrap() } + /// Get a specific HTTP request header by name as bytes. + /// + /// # Arguments + /// + /// * `name` - the name of the header + /// + /// # Returns + /// + /// * `Option` - the value of the header (wrapped in an Option) or `None` if the header does not exist + /// + /// # Example + /// + /// ```rust + /// use proxy_wasm::traits::*; + /// use proxy_wasm::types::*; + /// use log::debug; + /// + /// struct MyPlugin; + /// + /// impl HttpContext for MyPlugin { + /// fn on_http_request_headers(&mut self, _num_headers: usize, _end_of_stream: bool) -> Action { + /// let header = self.get_http_request_header_bytes(":path").unwrap(); + /// let header_str = String::from_utf8(header).unwrap(); + /// debug!("The path is: {:?}", header_str); + /// + /// Action::Continue + /// } + /// } + /// + /// # impl Context for MyPlugin {} + /// ``` fn get_http_request_header_bytes(&self, name: &str) -> Option { hostcalls::get_map_value_bytes(MapType::HttpRequestHeaders, name).unwrap() } @@ -343,6 +1309,31 @@ pub trait HttpContext: Context { hostcalls::set_map_value_bytes(MapType::HttpRequestHeaders, name, value).unwrap() } + /// Add a new HTTP request header to be sent upstream. + /// + /// # Arguments + /// + /// * `name` - the name of the header + /// * `value` - the value of the header + /// + /// # Example + /// + /// ```rust + /// use proxy_wasm::traits::*; + /// use proxy_wasm::types::*; + /// + /// struct MyPlugin; + /// + /// impl HttpContext for MyPlugin { + /// fn on_http_request_headers(&mut self, _num_headers: usize, _end_of_stream: bool) -> Action { + /// self.add_http_request_header("x-my-header", "my-value"); + /// + /// Action::Continue + /// } + /// } + /// + /// # impl Context for MyPlugin {} + /// ``` fn add_http_request_header(&self, name: &str, value: &str) { hostcalls::add_map_value(MapType::HttpRequestHeaders, name, value).unwrap() } @@ -407,6 +1398,7 @@ pub trait HttpContext: Context { hostcalls::add_map_value_bytes(MapType::HttpRequestTrailers, name, value).unwrap() } + /// Resumes processing of paused request. fn resume_http_request(&self) { hostcalls::resume_http_request().unwrap() } @@ -523,6 +1515,43 @@ pub trait HttpContext: Context { hostcalls::reset_http_response().unwrap() } + /// Sends an HTTP response with the specified status code, headers, and body. + /// + /// This can be used as long as HTTP response headers were not sent downstream yet. + /// + /// # Arguments + /// + /// * `status_code` - the HTTP status code + /// * `headers` - the HTTP headers as a `Vec` of `(&str, &str)` + /// * `body` - the HTTP body as a slice of bytes + /// + /// # Example + /// + /// ```rust + /// use log::info; + /// use proxy_wasm::traits::*; + /// use proxy_wasm::types::*; + /// + /// struct MyPlugin; + /// + /// impl HttpContext for MyPlugin { + /// fn on_http_request_headers(&mut self, _num_headers: usize, _end_of_stream: bool) -> Action { + /// let auth = self.get_http_request_header("Authorization").unwrap_or_default(); + /// + /// if auth == "I am authorized!" { + /// // Send an HTTP response with a status code of 200 and a body of "Hello, World!" + /// self.send_http_response(200, vec![("A header", "Some Value")], Some(b"Hello, World!")); + /// } else { + /// // Send an HTTP response with a status code of 307, redirecting to authenticate-here.com, and a body of "Forbidden" + /// self.send_http_response(307, vec![("location", "https://authenticate-here.com")], Some(b"Forbidden")); + /// } + /// + /// Action::Pause + /// } + /// } + /// + /// # impl Context for MyPlugin {} + /// ``` fn send_http_response( &self, status_code: u32,