From 8880918f1a2055b122ee99eb13002cf47bd6cd58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20K=C3=B6rber?= Date: Sat, 2 Nov 2024 13:37:44 +0100 Subject: [PATCH] Initial commit --- .gitignore | 3 + Cargo.lock | 1495 ++++++++++++++++++++++++++++++++++ Cargo.toml | 198 +++++ LICENSE | 674 +++++++++++++++ Makefile | 21 + aws_macros/Cargo.toml | 35 + aws_macros/src/lib.rs | 22 + aws_macros/src/tag.rs | 79 ++ aws_macros/src/tags.rs | 369 +++++++++ clippy.toml | 1 + src/error.rs | 110 +++ src/export.rs | 9 + src/lib.rs | 1046 ++++++++++++++++++++++++ src/tags/README.md | 72 ++ src/tags/error.rs | 127 +++ src/tags/helpers.rs | 49 ++ src/tags/mod.rs | 407 +++++++++ src/tags/predefined_types.rs | 23 + src/tags/svc.rs | 233 ++++++ 19 files changed, 4973 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 LICENSE create mode 100644 Makefile create mode 100644 aws_macros/Cargo.toml create mode 100644 aws_macros/src/lib.rs create mode 100644 aws_macros/src/tag.rs create mode 100644 aws_macros/src/tags.rs create mode 100644 clippy.toml create mode 100644 src/error.rs create mode 100644 src/export.rs create mode 100644 src/lib.rs create mode 100644 src/tags/README.md create mode 100644 src/tags/error.rs create mode 100644 src/tags/helpers.rs create mode 100644 src/tags/mod.rs create mode 100644 src/tags/predefined_types.rs create mode 100644 src/tags/svc.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ffeb9b2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/target +*.rdb +/Cargo.lock diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..823477a --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,1495 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "addr2line" +version = "0.24.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler2" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" + +[[package]] +name = "autocfg" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" + +[[package]] +name = "aws" +version = "0.1.0" +dependencies = [ + "aws-config", + "aws-macros", + "aws-sdk-cloudformation", + "aws-sdk-cloudfront", + "aws-sdk-ec2", + "aws-sdk-efs", + "aws-sdk-route53", + "chrono", + "serde", + "serde_json", +] + +[[package]] +name = "aws-config" +version = "1.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d6448cfb224dd6a9b9ac734f58622dd0d4751f3589f3b777345745f46b2eb14" +dependencies = [ + "aws-credential-types", + "aws-runtime", + "aws-sdk-sts", + "aws-smithy-async", + "aws-smithy-http", + "aws-smithy-json", + "aws-smithy-runtime", + "aws-smithy-runtime-api", + "aws-smithy-types", + "aws-types", + "bytes", + "fastrand", + "http 0.2.12", + "time", + "tokio", + "tracing", + "url", +] + +[[package]] +name = "aws-credential-types" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60e8f6b615cb5fc60a98132268508ad104310f0cfb25a1c22eee76efdf9154da" +dependencies = [ + "aws-smithy-async", + "aws-smithy-runtime-api", + "aws-smithy-types", + "zeroize", +] + +[[package]] +name = "aws-macros" +version = "0.1.0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "aws-runtime" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a10d5c055aa540164d9561a0e2e74ad30f0dcf7393c3a92f6733ddf9c5762468" +dependencies = [ + "aws-credential-types", + "aws-sigv4", + "aws-smithy-async", + "aws-smithy-http", + "aws-smithy-runtime", + "aws-smithy-runtime-api", + "aws-smithy-types", + "aws-types", + "bytes", + "fastrand", + "http 0.2.12", + "http-body 0.4.6", + "once_cell", + "percent-encoding", + "pin-project-lite", + "tracing", + "uuid", +] + +[[package]] +name = "aws-sdk-cloudformation" +version = "1.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a20536868bf10edac8b255eb6704eda7ae5d690866b352e1aac91567e77e80d" +dependencies = [ + "aws-credential-types", + "aws-runtime", + "aws-smithy-async", + "aws-smithy-http", + "aws-smithy-json", + "aws-smithy-query", + "aws-smithy-runtime", + "aws-smithy-runtime-api", + "aws-smithy-types", + "aws-smithy-xml", + "aws-types", + "fastrand", + "http 0.2.12", + "once_cell", + "regex-lite", + "tracing", +] + +[[package]] +name = "aws-sdk-cloudfront" +version = "1.50.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ffd017f74a346d71a81d357d262fc7b212743ad5723a83b258b54476425450e" +dependencies = [ + "aws-credential-types", + "aws-runtime", + "aws-smithy-async", + "aws-smithy-http", + "aws-smithy-json", + "aws-smithy-runtime", + "aws-smithy-runtime-api", + "aws-smithy-types", + "aws-smithy-xml", + "aws-types", + "http 0.2.12", + "once_cell", + "regex-lite", + "tracing", +] + +[[package]] +name = "aws-sdk-ec2" +version = "1.85.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99f19a036d84edc0f331404851f83921dded5001654df6095fb19d8957fb4ee3" +dependencies = [ + "aws-credential-types", + "aws-runtime", + "aws-smithy-async", + "aws-smithy-http", + "aws-smithy-json", + "aws-smithy-query", + "aws-smithy-runtime", + "aws-smithy-runtime-api", + "aws-smithy-types", + "aws-smithy-xml", + "aws-types", + "fastrand", + "http 0.2.12", + "once_cell", + "regex-lite", + "tracing", +] + +[[package]] +name = "aws-sdk-efs" +version = "1.49.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bd951c2be6b9168448f2ba978b82a0e0623009f2de57f21f6a232751a7985ac" +dependencies = [ + "aws-credential-types", + "aws-runtime", + "aws-smithy-async", + "aws-smithy-http", + "aws-smithy-json", + "aws-smithy-runtime", + "aws-smithy-runtime-api", + "aws-smithy-types", + "aws-types", + "bytes", + "fastrand", + "http 0.2.12", + "once_cell", + "regex-lite", + "tracing", +] + +[[package]] +name = "aws-sdk-route53" +version = "1.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b6da66bfdc0329ca5c93bd48f9b94843b30de804031b9fd31ca39eef27336d0" +dependencies = [ + "aws-credential-types", + "aws-runtime", + "aws-smithy-async", + "aws-smithy-http", + "aws-smithy-json", + "aws-smithy-runtime", + "aws-smithy-runtime-api", + "aws-smithy-types", + "aws-smithy-xml", + "aws-types", + "http 0.2.12", + "once_cell", + "regex-lite", + "tracing", +] + +[[package]] +name = "aws-sdk-sts" +version = "1.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "823ef553cf36713c97453e2ddff1eb8f62be7f4523544e2a5db64caf80100f0a" +dependencies = [ + "aws-credential-types", + "aws-runtime", + "aws-smithy-async", + "aws-smithy-http", + "aws-smithy-json", + "aws-smithy-query", + "aws-smithy-runtime", + "aws-smithy-runtime-api", + "aws-smithy-types", + "aws-smithy-xml", + "aws-types", + "http 0.2.12", + "once_cell", + "regex-lite", + "tracing", +] + +[[package]] +name = "aws-sigv4" +version = "1.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5619742a0d8f253be760bfbb8e8e8368c69e3587e4637af5754e488a611499b1" +dependencies = [ + "aws-credential-types", + "aws-smithy-http", + "aws-smithy-runtime-api", + "aws-smithy-types", + "bytes", + "form_urlencoded", + "hex", + "hmac", + "http 0.2.12", + "http 1.1.0", + "once_cell", + "percent-encoding", + "sha2", + "time", + "tracing", +] + +[[package]] +name = "aws-smithy-async" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62220bc6e97f946ddd51b5f1361f78996e704677afc518a4ff66b7a72ea1378c" +dependencies = [ + "futures-util", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "aws-smithy-http" +version = "0.60.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c8bc3e8fdc6b8d07d976e301c02fe553f72a39b7a9fea820e023268467d7ab6" +dependencies = [ + "aws-smithy-runtime-api", + "aws-smithy-types", + "bytes", + "bytes-utils", + "futures-core", + "http 0.2.12", + "http-body 0.4.6", + "once_cell", + "percent-encoding", + "pin-project-lite", + "pin-utils", + "tracing", +] + +[[package]] +name = "aws-smithy-json" +version = "0.60.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4683df9469ef09468dad3473d129960119a0d3593617542b7d52086c8486f2d6" +dependencies = [ + "aws-smithy-types", +] + +[[package]] +name = "aws-smithy-query" +version = "0.60.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2fbd61ceb3fe8a1cb7352e42689cec5335833cd9f94103a61e98f9bb61c64bb" +dependencies = [ + "aws-smithy-types", + "urlencoding", +] + +[[package]] +name = "aws-smithy-runtime" +version = "1.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be28bd063fa91fd871d131fc8b68d7cd4c5fa0869bea68daca50dcb1cbd76be2" +dependencies = [ + "aws-smithy-async", + "aws-smithy-http", + "aws-smithy-runtime-api", + "aws-smithy-types", + "bytes", + "fastrand", + "h2", + "http 0.2.12", + "http-body 0.4.6", + "http-body 1.0.1", + "httparse", + "hyper", + "hyper-rustls", + "once_cell", + "pin-project-lite", + "pin-utils", + "rustls", + "tokio", + "tracing", +] + +[[package]] +name = "aws-smithy-runtime-api" +version = "1.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e086682a53d3aa241192aa110fa8dfce98f2f5ac2ead0de84d41582c7e8fdb96" +dependencies = [ + "aws-smithy-async", + "aws-smithy-types", + "bytes", + "http 0.2.12", + "http 1.1.0", + "pin-project-lite", + "tokio", + "tracing", + "zeroize", +] + +[[package]] +name = "aws-smithy-types" +version = "1.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07c9cdc179e6afbf5d391ab08c85eac817b51c87e1892a5edb5f7bbdc64314b4" +dependencies = [ + "base64-simd", + "bytes", + "bytes-utils", + "futures-core", + "http 0.2.12", + "http 1.1.0", + "http-body 0.4.6", + "http-body 1.0.1", + "http-body-util", + "itoa", + "num-integer", + "pin-project-lite", + "pin-utils", + "ryu", + "serde", + "time", + "tokio", + "tokio-util", +] + +[[package]] +name = "aws-smithy-xml" +version = "0.60.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab0b0166827aa700d3dc519f72f8b3a91c35d0b8d042dc5d643a91e6f80648fc" +dependencies = [ + "xmlparser", +] + +[[package]] +name = "aws-types" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5221b91b3e441e6675310829fd8984801b772cb1546ef6c0e54dec9f1ac13fef" +dependencies = [ + "aws-credential-types", + "aws-smithy-async", + "aws-smithy-runtime-api", + "aws-smithy-types", + "rustc_version", + "tracing", +] + +[[package]] +name = "backtrace" +version = "0.3.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" +dependencies = [ + "addr2line", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", + "windows-targets", +] + +[[package]] +name = "base64" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + +[[package]] +name = "base64-simd" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "339abbe78e73178762e23bea9dfd08e697eb3f3301cd4be981c0f78ba5859195" +dependencies = [ + "outref", + "vsimd", +] + +[[package]] +name = "bitflags" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "bytes" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da" + +[[package]] +name = "bytes-utils" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dafe3a8757b027e2be6e4e5601ed563c55989fcf1546e933c66c8eb3a058d35" +dependencies = [ + "bytes", + "either", +] + +[[package]] +name = "cc" +version = "1.1.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3788d6ac30243803df38a3e9991cf37e41210232916d41a8222ae378f912624" +dependencies = [ + "shlex", +] + +[[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", + "serde", +] + +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "cpufeatures" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" +dependencies = [ + "libc", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "deranged" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +dependencies = [ + "powerfmt", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", + "subtle", +] + +[[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 = "fastrand" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "form_urlencoded" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures-channel" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" + +[[package]] +name = "futures-sink" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" + +[[package]] +name = "futures-task" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" + +[[package]] +name = "futures-util" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" +dependencies = [ + "futures-core", + "futures-task", + "pin-project-lite", + "pin-utils", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[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.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" + +[[package]] +name = "h2" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http 0.2.12", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" + +[[package]] +name = "hermit-abi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest", +] + +[[package]] +name = "http" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[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 = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" +dependencies = [ + "bytes", + "http 0.2.12", + "pin-project-lite", +] + +[[package]] +name = "http-body" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http 1.1.0", +] + +[[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 1.1.0", + "http-body 1.0.1", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "hyper" +version = "0.14.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c08302e8fa335b151b788c775ff56e7a03ae64ff85c548ee820fecb70356e85" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http 0.2.12", + "http-body 0.4.6", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.24.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" +dependencies = [ + "futures-util", + "http 0.2.12", + "hyper", + "log", + "rustls", + "rustls-native-certs", + "tokio", + "tokio-rustls", +] + +[[package]] +name = "idna" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "indexmap" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[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.161" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" + +[[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 = "miniz_oxide" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" +dependencies = [ + "adler2", +] + +[[package]] +name = "mio" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" +dependencies = [ + "hermit-abi", + "libc", + "wasi", + "windows-sys 0.52.0", +] + +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[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.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" + +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "outref" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4030760ffd992bef45b0ae3f10ce1aba99e33464c90d14dd7c039884963ddc7a" + +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + +[[package]] +name = "pin-project-lite" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + +[[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 = "quote" +version = "1.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "regex-lite" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53a49587ad06b26609c52e423de037e7f57f20d53535d66e08c695f347df952a" + +[[package]] +name = "ring" +version = "0.17.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" +dependencies = [ + "cc", + "cfg-if", + "getrandom", + "libc", + "spin", + "untrusted", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" + +[[package]] +name = "rustc_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver", +] + +[[package]] +name = "rustls" +version = "0.21.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" +dependencies = [ + "log", + "ring", + "rustls-webpki", + "sct", +] + +[[package]] +name = "rustls-native-certs" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00" +dependencies = [ + "openssl-probe", + "rustls-pemfile", + "schannel", + "security-framework", +] + +[[package]] +name = "rustls-pemfile" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" +dependencies = [ + "base64", +] + +[[package]] +name = "rustls-webpki" +version = "0.101.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] +name = "schannel" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01227be5826fa0690321a2ba6c5cd57a19cf3f6a09e76973b58e61de6ab9d1c1" +dependencies = [ + "windows-sys 0.59.0", +] + +[[package]] +name = "sct" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "security-framework" +version = "2.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea4a292869320c0272d7bc55a5a6aafaff59b4f63404a003887b679a2e05b4b6" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "semver" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" + +[[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 = "sha2" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + +[[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 = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "syn" +version = "2.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e89275301d38033efb81a6e60e3497e734dfcc62571f2854bf4b16690398824c" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "time" +version = "0.3.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" +dependencies = [ + "deranged", + "num-conv", + "powerfmt", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" + +[[package]] +name = "time-macros" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" +dependencies = [ + "num-conv", + "time-core", +] + +[[package]] +name = "tinyvec" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tokio" +version = "1.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "145f3413504347a2be84393cc8a7d2fb4d863b375909ea59f2158261aa258bbb" +dependencies = [ + "backtrace", + "bytes", + "libc", + "mio", + "pin-project-lite", + "socket2", + "windows-sys 0.52.0", +] + +[[package]] +name = "tokio-rustls" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" +dependencies = [ + "rustls", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + +[[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 = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "unicode-bidi" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ab17db44d7388991a428b2ee655ce0c212e862eff1768a455c58f9aad6e7893" + +[[package]] +name = "unicode-ident" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" + +[[package]] +name = "unicode-normalization" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "url" +version = "2.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "urlencoding" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" + +[[package]] +name = "uuid" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8c5f0a0af699448548ad1a2fbf920fb4bee257eae39953ba95cb84891a0446a" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "vsimd" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c3082ca00d5a5ef149bb8b555a72ae84c9c59f7250f013ac822ac2e49b19c64" + +[[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.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[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.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[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.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[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.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "xmlparser" +version = "0.13.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66fee0b777b0f5ac1c69bb06d361268faafa61cd4682ae064a171c16c433e9e4" + +[[package]] +name = "zeroize" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..33d5192 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,198 @@ +[package] +name = "aws" +version.workspace = true +edition.workspace = true +rust-version.workspace = true + +authors.workspace = true +description.workspace = true +license.workspace = true +repository.workspace = true +keywords.workspace = true +categories.workspace = true +readme.workspace = true + +[workspace.package] +version = "0.1.0" +edition = "2021" +rust-version = "1.81" + +authors = ["Hannes Körber "] +description = "Helper functions and types for AWS operations" +license = "GPL-3.0-only" +repository = "https://github.com/hakoerber/aws-rs" +keywords = ["aws"] +categories = ["api-bindings"] +readme = "README.md" + +[dependencies] +aws-macros = { path = "./aws_macros" } +aws-config = { version = "1.*", default-features = false } +aws-sdk-ec2 = { version = "1.*", default-features = false, features = [ + "rustls", + "rt-tokio", +] } +aws-sdk-cloudfront = { version = "1.*", default-features = false, features = [ + "rustls", + "rt-tokio", +] } +aws-sdk-efs = { version = "1.*", default-features = false, features = [ + "rustls", + "rt-tokio", +] } +aws-sdk-route53 = { version = "1.*", default-features = false, features = [ + "rustls", + "rt-tokio", +] } +aws-sdk-cloudformation = { version = "1.*", default-features = false, features = [ + "rustls", + "rt-tokio", +] } +chrono = { version = "0.4.*", default-features = false, features = [ + "std", + "now", + "serde", +] } +serde = { version = "1.*", default-features = false, features = [ + "std", + "derive", +] } +serde_json = { version = "1.*", default-features = false, features = ["std"] } + +[workspace] +resolver = "2" +members = ["aws_macros"] + +[lints] +workspace = true + +[profile.release] +opt-level = 3 +debug = false +strip = "symbols" +debug-assertions = false +overflow-checks = false +lto = "fat" +panic = "abort" +codegen-units = 1 +rpath = false + +[workspace.lints.rust] +absolute_paths_not_starting_with_crate = "deny" +elided_lifetimes_in_paths = "deny" +explicit_outlives_requirements = "deny" +keyword_idents = "deny" +let_underscore_drop = "deny" +non_ascii_idents = "deny" +non_local_definitions = "deny" +single_use_lifetimes = "deny" +unit_bindings = "deny" +unreachable_pub = "deny" +unsafe_code = { level = "forbid", priority = -1 } +unsafe_op_in_unsafe_fn = "deny" +unstable_features = { level = "forbid", priority = -1 } +unused_crate_dependencies = "deny" +unused_import_braces = "deny" +unused_lifetimes = "deny" +unused_macro_rules = "deny" +unused_qualifications = "deny" +unused_results = "deny" +variant_size_differences = "deny" + +[workspace.lints.clippy] +missing_errors_doc = "allow" +redundant_pub_crate = "allow" +must_use_candidate = "allow" +missing_const_for_fn = "warn" +too_many_lines = "allow" +too_many_arguments = "allow" +option_if_let_else = "allow" +match_bool = "allow" +new_without_default = "allow" +missing_panics_doc = "warn" +multiple_crate_versions = "allow" + +pedantic = { level = "deny", priority = -1 } +nursery = { level = "deny", priority = -1 } +cargo = { level = "deny", priority = -1 } + +# restrictions +renamed_function_params = "deny" +allow_attributes = "deny" +allow_attributes_without_reason = "deny" +dbg_macro = "deny" +arithmetic_side_effects = "deny" +as_conversions = "deny" +assertions_on_result_states = "deny" +clone_on_ref_ptr = "deny" +create_dir = "deny" +decimal_literal_representation = "deny" +default_numeric_fallback = "deny" +deref_by_slicing = "deny" +disallowed_script_idents = "deny" +else_if_without_else = "deny" +empty_drop = "deny" +empty_enum_variants_with_brackets = "deny" +empty_structs_with_brackets = "deny" +exit = "deny" +expect_used = "allow" +filetype_is_file = "deny" +float_arithmetic = "deny" +float_cmp_const = "deny" +fn_to_numeric_cast_any = "deny" +format_push_string = "deny" +get_unwrap = "deny" +if_then_some_else_none = "deny" +impl_trait_in_params = "allow" +indexing_slicing = "deny" +infinite_loop = "deny" +inline_asm_x86_att_syntax = "deny" +inline_asm_x86_intel_syntax = "deny" +integer_division = "deny" +iter_over_hash_type = "deny" +large_include_file = "deny" +let_underscore_must_use = "deny" +let_underscore_untyped = "deny" +little_endian_bytes = "deny" +lossy_float_literal = "deny" +map_err_ignore = "deny" +mem_forget = "deny" +missing_assert_message = "deny" +missing_asserts_for_indexing = "deny" +mixed_read_write_in_expression = "deny" +mod_module_files = "allow" +modulo_arithmetic = "deny" +multiple_inherent_impl = "deny" +multiple_unsafe_ops_per_block = "deny" +mutex_atomic = "deny" +panic = "deny" +panic_in_result_fn = "deny" +partial_pub_fields = "deny" +pattern_type_mismatch = "deny" +pub_without_shorthand = "deny" +rc_buffer = "deny" +rc_mutex = "deny" +redundant_type_annotations = "deny" +rest_pat_in_fully_bound_structs = "deny" +same_name_method = "deny" +self_named_module_files = "deny" +semicolon_outside_block = "deny" +single_char_lifetime_names = "allow" +str_to_string = "deny" +string_add = "deny" +string_lit_chars_any = "deny" +string_slice = "deny" +string_to_string = "deny" +suspicious_xor_used_as_pow = "deny" +tests_outside_test_module = "deny" +try_err = "deny" +undocumented_unsafe_blocks = "deny" +unimplemented = "deny" +unnecessary_safety_comment = "deny" +unnecessary_safety_doc = "deny" +unnecessary_self_imports = "deny" +unneeded_field_pattern = "deny" +unseparated_literal_suffix = "deny" +unwrap_used = "deny" +use_debug = "deny" +verbose_file_reads = "deny" diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f288702 --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..c007fb7 --- /dev/null +++ b/Makefile @@ -0,0 +1,21 @@ +.PHONY: docs +docs: + cargo watch -- cargo doc + +.PHONY: test +test: + @cargo test --workspace --color=always + +.PHONY: lint +lint: + @cargo clippy --workspace --tests --color=always + +.PHONY: fmt +fmt: + cargo fmt + find -name '*.md' | xargs prettier --print-width 80 --prose-wrap always --write + find -name '*.toml' | xargs taplo format + +.PHONY: build-static +build-static: + cargo build --target x86_64-unknown-linux-musl --no-default-features --release --workspace diff --git a/aws_macros/Cargo.toml b/aws_macros/Cargo.toml new file mode 100644 index 0000000..830bc98 --- /dev/null +++ b/aws_macros/Cargo.toml @@ -0,0 +1,35 @@ +[package] +name = "aws-macros" +version.workspace = true +edition.workspace = true +rust-version.workspace = true + +authors.workspace = true +description.workspace = true +license.workspace = true +repository.workspace = true +keywords.workspace = true +categories.workspace = true +readme.workspace = true + +[lib] +name = "aws_macros" +path = "src/lib.rs" +proc-macro = true + +[dependencies] +proc-macro2 = { version = "1.*", default-features = false, features = [ + "proc-macro", +] } +quote = { version = "1.*", default-features = false } +syn = { version = "2.*", default-features = false, features = [ + "full", + "extra-traits", + "proc-macro", + "parsing", + "printing", + "clone-impls", +] } + +[lints] +workspace = true diff --git a/aws_macros/src/lib.rs b/aws_macros/src/lib.rs new file mode 100644 index 0000000..2ffeed5 --- /dev/null +++ b/aws_macros/src/lib.rs @@ -0,0 +1,22 @@ +#![expect( + clippy::expect_used, + clippy::panic, + reason = "panics and expects are fine for proc macros" +)] + +use proc_macro::TokenStream; + +mod tag; +mod tags; + +#[proc_macro_attribute] +#[expect(non_snake_case, reason = "attribute proc macros should be capitalized")] +pub fn Tags(attr: TokenStream, item: TokenStream) -> TokenStream { + tags::transform(attr, item) +} + +#[proc_macro_attribute] +#[expect(non_snake_case, reason = "attribute proc macros should be capitalized")] +pub fn Tag(attr: TokenStream, item: TokenStream) -> TokenStream { + tag::transform(attr, item) +} diff --git a/aws_macros/src/tag.rs b/aws_macros/src/tag.rs new file mode 100644 index 0000000..bbc8334 --- /dev/null +++ b/aws_macros/src/tag.rs @@ -0,0 +1,79 @@ +use proc_macro::TokenStream; +use quote::quote; + +#[derive(Debug)] +enum Translator { + Serde, + Manual, +} + +pub(crate) fn transform(attr: TokenStream, item: TokenStream) -> TokenStream { + let root = quote! {::aws}; + + let expr: syn::Expr = syn::parse(attr).expect("expected expr in macro attribute"); + + let syn::Expr::Assign(assign) = expr else { + panic!("invalid expression in macro attribute") + }; + + match *assign.left { + syn::Expr::Path(ref exprpath) => { + let segments = &exprpath.path.segments; + let (Some(segment), 1) = (segments.first(), segments.len()) else { + panic!("invalid attribute key") + }; + + assert!(segment.ident == "translate", "invalid attribute key"); + } + _ => panic!("invalid expression in tag field attribute, left side"), + } + + let translator = match *assign.right { + syn::Expr::Path(ref exprpath) => { + let segments = &exprpath.path.segments; + let (Some(segment), 1) = (segments.first(), segments.len()) else { + panic!("invalid attribute key") + }; + + match segment.ident.to_string().as_str() { + "serde" => Translator::Serde, + "manual" => Translator::Manual, + t => panic!("invalid translator {t}"), + } + } + _ => panic!("invalid expression in tag field attribute, left side"), + }; + + let elem = syn::parse_macro_input!(item as syn::Item); + + let name = match elem { + syn::Item::Struct(ref s) => &s.ident, + syn::Item::Enum(ref e) => &e.ident, + _ => panic!("only applicable to structs/enums"), + }; + + let translator = match translator { + Translator::Serde => quote! { + impl #root::tags::TranslatableSerde for #name {} + + impl #root::tags::TagValue<#name> for #name { + type Error = #root::tags::ParseTagValueError; + type Translator = #root::tags::TranslateSerde; + } + }, + Translator::Manual => quote! { + impl #root::tags::TranslatableManual for #name {} + + impl #root::tags::TagValue<#name> for #name { + type Error = #root::tags::ParseTagValueError; + type Translator = #root::tags::TranslateManual; + } + }, + }; + + quote! { + #elem + #translator + } + .into() +} diff --git a/aws_macros/src/tags.rs b/aws_macros/src/tags.rs new file mode 100644 index 0000000..582065d --- /dev/null +++ b/aws_macros/src/tags.rs @@ -0,0 +1,369 @@ +use proc_macro::TokenStream; +use quote::quote; + +#[derive(Debug)] +struct Input { + ident: syn::Ident, + vis: syn::Visibility, + elements: Vec, +} + +#[derive(Debug)] +enum ElementKind { + Required, + Optional, +} + +#[derive(Debug)] +struct Element { + ident: syn::Ident, + vis: syn::Visibility, + ty: syn::Path, + kind: ElementKind, + name: String, +} + +fn parse_type(input: syn::Type) -> (syn::Path, ElementKind) { + match input { + syn::Type::Path(ty) => { + let segments = ty.path.segments.clone(); + let first = segments.first().expect("segments is empty"); + + let (ident, optional) = match first.ident.to_string().as_str() { + "Option" => match first.arguments { + // It may not be required to parse this, we could just + // extract the inner type and let the compiler beat the + // caller up if there is some bullshit happening. + syn::PathArguments::AngleBracketed(ref genargs) => { + let mut args = genargs.args.clone(); + match genargs.args.len() { + 1 => { + let ty = args.pop().expect("genargs are empty"); + let ty = match ty { + syn::punctuated::Pair::Punctuated(node, _punct) => node, + syn::punctuated::Pair::End(node) => node, + }; + match ty { + syn::GenericArgument::Type(ty) => match ty { + syn::Type::Path(ty) => (ty, ElementKind::Optional), + _ => panic!("invalid generic type for Option"), + }, + + _ => panic!("need simple owned Option generic"), + } + } + _ => panic!("wrong number of Option generic arguments"), + } + } + _ => panic!("invalid Option usage"), + }, + _ => (ty, ElementKind::Required), + }; + + (ident.path, optional) + } + _ => panic!("invalid field type"), + } +} + +fn parse_field_attrs(attrs: &[syn::Attribute]) -> Option { + match (attrs.first(), attrs.len()) { + (Some(attr), 1) => { + assert!( + attr.style == syn::AttrStyle::Outer, + "field attribute style needs to be an outer attribute" + ); + match attr.meta { + syn::Meta::List(ref meta_list) => { + let tag = &meta_list.path; + let tag_name = match (tag.segments.first(), tag.segments.len()) { + (Some(segment), 1) => segment.ident.to_string(), + (_, 0) => return None, + _ => panic!("invalid field attribute path"), + }; + assert!(tag_name == "tag", "invalid field attribute path {tag_name}"); + + let expr: syn::Expr = match meta_list.parse_args() { + Ok(expr) => expr, + Err(e) => panic!("failed parsing tag field attribute: {e}"), + }; + + let syn::Expr::Assign(assign) = expr else { + panic!("invalid expression in tag field attribute") + }; + + match *assign.left { + syn::Expr::Path(ref exprpath) => { + let segments = &exprpath.path.segments; + let (Some(segment), 1) = (segments.first(), segments.len()) else { + panic!("invalid tag field attribute key") + }; + + assert!(segment.ident == "key", "invalid tag field attribute key"); + } + _ => panic!("invalid expression in tag field attribute, left side"), + } + + match *assign.right { + syn::Expr::Lit(ref expr_lit) => match expr_lit.lit { + syn::Lit::Str(ref lit_str) => Some(lit_str.value()), + _ => panic!("right side of tag field not a string literal"), + }, + _ => panic!("right side of tag field attribute not a literal"), + } + } + _ => panic!("invalid field attribute"), + } + } + (_, 0) => None, + _ => panic!("invalid field attributes"), + } +} + +fn parse_fields(input: impl IntoIterator) -> Vec { + let mut elements = Vec::new(); + for field in input { + let ident = field.ident.expect("tuple structs not supported"); + let vis = field.vis; + let (ty, kind) = parse_type(field.ty); + + let name = parse_field_attrs(&field.attrs); + + elements.push(Element { + ident: ident.clone(), + vis, + ty, + kind, + name: name.unwrap_or_else(|| ident.to_string()), + }); + } + elements +} + +fn parse_struct(input: syn::ItemStruct) -> Input { + Input { + ident: input.ident, + vis: input.vis, + elements: match input.fields { + syn::Fields::Named(fields) => parse_fields(fields.named), + _ => panic!("invalid fields"), + }, + } +} + +fn build_output(input: Input) -> TokenStream { + let root = quote! { ::aws }; + + let ident = input.ident; + let vis = input.vis; + + let type_definition = { + let elements: Vec = input + .elements + .iter() + .map(|element| { + let ident = &element.ident; + let vis = &element.vis; + let ty = &element.ty; + match element.kind { + ElementKind::Required => { + quote!( + #vis #ident: #ty + ) + } + ElementKind::Optional => { + quote!( + #vis #ident: ::std::option::Option<#ty> + ) + } + } + }) + .collect(); + + quote! { + #vis struct #ident { + #(#elements),* + } + } + }; + + let impls = { + let params = input.elements.iter().map(|element| { + let ident = &element.ident; + let ty = &element.ty; + match element.kind { + ElementKind::Required => quote!(#ident: #ty), + ElementKind::Optional => quote!(#ident: ::std::option::Option<#ty>), + } + }); + + let from_fields: Vec = input + .elements + .iter() + .map(|element| { + let ident = &element.ident; + quote! {#ident: #ident} + }) + .collect(); + + let from_tags_fields: Vec= input.elements.iter().map(|element| { + let ident = &element.ident; + let ty = &element.ty; + let tag_name = &element.name; + + let try_convert = quote!{ + let value: ::std::result::Result<#ty, #root::tags::ParseTagsError> = <#ty as #root::tags::TagValue<#ty>>::from_raw_tag(value) + .map_err( + |e| #root::tags::ParseTagsError::ParseTag(#root::tags::ParseTagError::InvalidTagValue { + key, + inner: <<#ty as #root::tags::TagValue<#ty>>::Error as Into<#root::tags::ParseTagValueError>>::into(e), + } + ) + ); + + let value = match value { + ::std::result::Result::Ok(v) => v, + ::std::result::Result::Err(e) => { + return Err(e); + } + }; + + value + }; + + let transformer = match element.kind { + ElementKind::Required => { + quote! { + let value: #root::tags::RawTagValue = value.ok_or_else(|| #root::tags::ParseTagsError::TagNotFound { + key: key.clone() + })? + .clone(); + + let value = { + #try_convert + }; + + value + + } + } + ElementKind::Optional => { + quote! { + let value: ::std::option::Option<#ty> = value.map(|value: #root::tags::RawTagValue| { + let value = { + #try_convert + }; + Ok(value) + }).transpose()?; + value + } + } + }; + + quote! { + #ident: { + let key: #root::tags::TagKey = #root::tags::TagKey::new(#tag_name.to_owned()); + + let value: ::std::option::Option<#root::tags::RawTagValue> = tags + .as_slice() + .iter() + .find(|tag| tag.key() == #tag_name) + .map(|tag| tag.value()).cloned(); + + let value = { + #transformer + }; + + value + } + } + }).collect(); + + let fields_to_tags: Vec = input + .elements + .iter() + .map(|element| { + let ident = &element.ident; + let ty= &element.ty; + let tag_name = &element.name; + match element.kind { + ElementKind::Required => { + quote! { + { + let key = #root::tags::TagKey::new(#tag_name.to_owned()); + let value: #root::tags::RawTagValue = <#ty as #root::tags::TagValue<#ty>>::into_raw_tag(self.#ident); + v.push(#root::tags::RawTag::new(key, value)); + } + } + } + ElementKind::Optional => { + quote! { + { + match self.#ident { + ::std::option::Option::Some(value) => { + let key = #root::tags::TagKey::new(#tag_name.to_owned()); + let value: #root::tags::RawTagValue = <#ty as #root::tags::TagValue<#ty>>::into_raw_tag(value); + v.push(#root::tags::RawTag::new(key, value)); + }, + ::std::option::Option::None => { + // do not serialize none values + }, + } + } + } + } + } + }) + .collect(); + + quote! { + impl #ident { + #vis fn from_values(#(#params),*) -> Self { + Self { + #(#from_fields),* + } + } + + #vis fn from_tags(tags: #root::tags::TagList) -> Result { + Ok(Self { + #(#from_tags_fields),* + }) + } + + #vis fn into_tags(self) -> #root::tags::TagList { + let mut v = ::std::vec::Vec::new(); + { + #(#fields_to_tags);*; + } + #root::tags::TagList::from_vec(v) + } + } + } + }; + + quote! { + #type_definition + #impls + } + .into() +} + +#[expect( + clippy::needless_pass_by_value, + reason = "this is the usual signature for proc macros, and the inner function should have the same signature" +)] +pub(crate) fn transform(attr: TokenStream, item: TokenStream) -> TokenStream { + assert!( + attr.is_empty(), + "cannot take any attribute macro attributes" + ); + + let input = syn::parse_macro_input!(item as syn::Item); + + let input = match input { + syn::Item::Struct(s) => parse_struct(s), + _ => panic!("only applicable to structs"), + }; + + build_output(input) +} diff --git a/clippy.toml b/clippy.toml new file mode 100644 index 0000000..154626e --- /dev/null +++ b/clippy.toml @@ -0,0 +1 @@ +allow-unwrap-in-tests = true diff --git a/src/error.rs b/src/error.rs new file mode 100644 index 0000000..f59760f --- /dev/null +++ b/src/error.rs @@ -0,0 +1,110 @@ +use std::{fmt, net, time::Duration}; + +use crate::tags::{ParseTagError, ParseTagsError}; + +#[derive(Debug)] +pub enum Error { + UnexpectedNoneValue { + entity: String, + }, + SdkError(Box), + InvalidResponseError { + message: String, + }, + MultipleMatches { + entity: String, + }, + InvalidTag(ParseTagError), + InvalidTags(ParseTagsError), + RunInstancesEmptyResponse, + InstanceStopExceededMaxWait { + max_wait: Duration, + instance: super::InstanceId, + }, + WaitError(Box), + RunInstanceNoCapacity, + InvalidTimestampError { + value: String, + message: String, + }, +} + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match *self { + Self::InvalidTag(ref inner) => { + write!(f, "{inner}") + } + Self::InvalidTags(ref inner) => { + write!(f, "{inner}") + } + Self::UnexpectedNoneValue { ref entity } => { + write!(f, "entity \"{entity}\" was empty") + } + Self::SdkError(ref e) => write!(f, "sdk error: {e}"), + Self::InvalidResponseError { ref message } => { + write!(f, "invalid api response: {message}") + } + Self::MultipleMatches { ref entity } => { + write!(f, "multiple matches for {entity} found") + } + Self::RunInstancesEmptyResponse => { + write!(f, "empty instance response of RunInstances") + } + Self::InstanceStopExceededMaxWait { + ref max_wait, + ref instance, + } => { + write!( + f, + "instance {instance} did not wait in {} seconds", + max_wait.as_secs() + ) + } + Self::WaitError(ref e) => write!(f, "waiter error: {e}"), + Self::RunInstanceNoCapacity => { + write!(f, "no capacity for rnu instance operation") + } + Self::InvalidTimestampError { + ref value, + ref message, + } => { + write!(f, "failed parsing \"{value}\" as timestamp: {message}") + } + } + } +} + +impl std::error::Error for Error {} + +impl From> for Error { + fn from(value: aws_sdk_ec2::error::SdkError) -> Self { + Self::SdkError(Box::new(value)) + } +} + +impl From for Error { + fn from(value: aws_sdk_ec2::waiters::instance_stopped::WaitUntilInstanceStoppedError) -> Self { + Self::WaitError(Box::new(value)) + } +} + +impl From for Error { + fn from(value: net::AddrParseError) -> Self { + Self::InvalidResponseError { + message: value.to_string(), + } + } +} + +impl From for Error { + fn from(value: ParseTagError) -> Self { + Self::InvalidTag(value) + } +} + +impl From for Error { + fn from(value: ParseTagsError) -> Self { + Self::InvalidTags(value) + } +} diff --git a/src/export.rs b/src/export.rs new file mode 100644 index 0000000..77e2847 --- /dev/null +++ b/src/export.rs @@ -0,0 +1,9 @@ +//! Re-exports selected elements of the EC2 SDK + +pub mod ec2 { + #![expect(clippy::module_name_repetitions, reason = "error prefix is necessary")] + pub mod error { + pub use aws_sdk_ec2::error::SdkError; + } + pub use aws_sdk_ec2::types::{Filter, InstanceStateName, InstanceType, Tag}; +} diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..55e9141 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,1046 @@ +//! Provides an opinionated interface to the AWS API + +extern crate self as aws; + +use std::{ + fmt::{self, Debug}, + net, + time::Duration, +}; + +use aws_config::retry::RetryConfig; +use aws_sdk_ec2::client::Waiters; +use chrono::{DateTime, Utc}; +use serde::{Deserialize, Serialize}; + +mod error; +pub use error::Error; + +pub mod tags; +use tags::{ParseTagValueError, RawTag, RawTagValue, Tag, TagKey, TagList}; + +pub mod export; + +macro_rules! wrap_aws_enum { + ($name:ident) => { + #[derive(Debug, Clone)] + pub struct $name(aws_sdk_ec2::types::$name); + + impl $name { + pub const fn new(from: aws_sdk_ec2::types::$name) -> Self { + Self(from) + } + + pub const fn inner(&self) -> &aws_sdk_ec2::types::$name { + &self.0 + } + + pub fn into_inner(self) -> aws_sdk_ec2::types::$name { + self.0 + } + } + + impl Serialize for $name { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(&self.inner().as_str()) + } + } + + impl<'de> Deserialize<'de> for $name { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + Ok(Self(String::deserialize(deserializer)?.as_str().into())) + } + } + + impl fmt::Display for $name { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{}", self.inner().to_string()) + } + } + }; +} + +wrap_aws_enum!(InstanceStateName); +wrap_aws_enum!(InstanceType); + +#[derive(Debug)] +pub struct Instance { + tags: TagList, + instance_type: InstanceType, + state: InstanceStateName, + instance_id: InstanceId, + image_id: AmiId, + subnet_id: SubnetId, + public_ip_address: Option, +} + +impl Instance { + pub fn try_from_aws(instance: aws_sdk_ec2::types::Instance) -> Result { + macro_rules! extract { + ($instance:ident, $field:ident) => { + $instance + .$field + .clone() // not ideal + .ok_or_else(|| Error::UnexpectedNoneValue { + entity: stringify!($field).to_owned(), + }) + }; + } + + Ok(Self { + tags: extract!(instance, tags)?.try_into()?, + instance_type: InstanceType(extract!(instance, instance_type)?), + state: InstanceStateName(extract!(instance, state)?.name.ok_or_else(|| { + Error::UnexpectedNoneValue { + entity: "state.name".to_owned(), + } + })?), + instance_id: InstanceId(extract!(instance, instance_id)?), + image_id: AmiId(extract!(instance, image_id)?), + subnet_id: SubnetId(extract!(instance, subnet_id)?), + public_ip_address: instance + .public_ip_address + .map(|s| -> Result<_, Error> { Ok(Ip(s.parse()?)) }) + .transpose()?, + }) + } + + pub fn get_tag(&self, key: TagKey) -> Option<&RawTag> { + self.tags.get(key) + } + + pub const fn tags(&self) -> &TagList { + &self.tags + } + + pub const fn instance_type(&self) -> &InstanceType { + &self.instance_type + } + + pub const fn state(&self) -> &InstanceStateName { + &self.state + } + + pub const fn instance_id(&self) -> &InstanceId { + &self.instance_id + } + + pub const fn image_id(&self) -> &AmiId { + &self.image_id + } + + pub const fn subnet_id(&self) -> &SubnetId { + &self.subnet_id + } + + pub const fn public_ip_address(&self) -> Option<&Ip> { + self.public_ip_address.as_ref() + } + + pub async fn stop(&self, client: &RegionClient) -> Result<(), Error> { + let _state_change_info = client + .main + .ec2 + .stop_instances() + .instance_ids(self.instance_id().as_str()) + .send() + .await?; + + Ok(()) + } + + pub async fn wait_for_stop( + &self, + client: &RegionClient, + max_wait: Duration, + ) -> Result<(), Error> { + match client + .main + .ec2 + .wait_until_instance_stopped() + .instance_ids(self.instance_id().as_str()) + .wait(max_wait) + .await + { + Ok(_final_response) => Ok(()), + Err(e) => match e { + aws_sdk_ec2::waiters::instance_stopped::WaitUntilInstanceStoppedError::ExceededMaxWait(_) => Err(Error::InstanceStopExceededMaxWait { max_wait, instance: self.instance_id().clone()}), + _ => Err(e.into()) + }, + }?; + + Ok(()) + } + + pub async fn add_tag(&self, client: &RegionClient, tag: Tag) -> Result<(), Error> + where + T: Debug + Clone + PartialEq + Eq + Into + Send, + T: tags::TagValue, + { + let _output = client + .main + .ec2 + .create_tags() + .resources(self.instance_id().as_str()) + .tags(tag.into()) + .send() + .await?; + + Ok(()) + } +} + +#[derive(Serialize, Deserialize, Debug, Copy, Clone)] +pub enum Region { + #[serde(rename = "eu-central-1")] + EuCentral1, + #[serde(rename = "us-east-1")] + UsEast1, +} + +impl fmt::Display for Region { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{}", self.as_str()) + } +} + +#[derive(Debug)] +pub struct ShieldPop(String); + +impl ShieldPop { + pub fn into_string(self) -> String { + self.0 + } +} + +impl Region { + pub const fn as_str(self) -> &'static str { + match self { + Self::EuCentral1 => "eu-central-1", + Self::UsEast1 => "us-east-1", + } + } + + pub const fn all() -> [Self; 2] { + [Self::EuCentral1, Self::UsEast1] + } + + const fn name(self) -> &'static str { + match self { + Self::EuCentral1 => "eu-central-1", + Self::UsEast1 => "us-east-1", + } + } + + pub fn cdn_shield_pop(self) -> ShieldPop { + ShieldPop( + match self { + Self::EuCentral1 => "eu-central-1", + Self::UsEast1 => "us-east-1", + } + .to_owned(), + ) + } +} + +#[derive(Debug, Clone)] +pub struct RegionClientMain { + pub ec2: aws_sdk_ec2::Client, + pub efs: aws_sdk_efs::Client, + pub route53: aws_sdk_route53::Client, +} + +#[derive(Debug, Clone)] +pub struct RegionClientCdn { + pub cloudfront: aws_sdk_cloudfront::Client, + pub cloudformation: aws_sdk_cloudformation::Client, +} + +#[derive(Debug, Clone)] +pub struct RegionClient { + pub region: Region, + pub main: RegionClientMain, + pub cdn: RegionClientCdn, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct InstanceProfileName(String); + +impl InstanceProfileName { + pub fn as_str(&self) -> &str { + &self.0 + } +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct InstanceKeypairName(String); + +impl InstanceKeypairName { + pub fn as_str(&self) -> &str { + &self.0 + } +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct SecurityGroupId(String); + +impl SecurityGroupId { + pub fn as_str(&self) -> &str { + &self.0 + } +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct SecurityGroup { + id: SecurityGroupId, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct SubnetId(String); + +impl SubnetId { + pub fn as_str(&self) -> &str { + &self.0 + } + + pub const fn from_string(value: String) -> Self { + Self(value) + } +} + +impl PartialEq for SubnetId { + fn eq(&self, other: &Self) -> bool { + self.0 == other.0 + } +} + +impl fmt::Display for SubnetId { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{}", self.0) + } +} + +macro_rules! string_newtype { + ($name:ident) => { + #[Tag(translate = serde)] + #[derive(Debug, Serialize, Deserialize, Clone, Eq, PartialEq)] + pub struct $name(String); + + impl std::fmt::Display for $name { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{}", self.0) + } + } + }; +} + +string_newtype!(AvailabilityZone); + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct Subnet { + pub id: SubnetId, + pub availability_zone: AvailabilityZone, +} + +impl TryFrom for Subnet { + type Error = Error; + + fn try_from(subnet: aws_sdk_ec2::types::Subnet) -> Result { + macro_rules! extract { + ($field:ident) => { + subnet.$field.ok_or_else(|| Error::UnexpectedNoneValue { + entity: stringify!($field).to_owned(), + }) + }; + } + + Ok(Self { + id: SubnetId(extract!(subnet_id)?), + availability_zone: AvailabilityZone(extract!(availability_zone)?), + }) + } +} + +string_newtype!(InstanceId); + +impl InstanceId { + pub fn as_str(&self) -> &str { + &self.0 + } +} + +string_newtype!(AmiId); + +impl AmiId { + pub fn as_str(&self) -> &str { + &self.0 + } +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct Ami { + pub id: AmiId, + pub tags: TagList, + pub creation_date: Timestamp, +} + +impl TryFrom for Ami { + type Error = Error; + + fn try_from(image: aws_sdk_ec2::types::Image) -> Result { + macro_rules! extract { + ($field:ident) => { + image.$field.ok_or_else(|| Error::UnexpectedNoneValue { + entity: stringify!($field).to_owned(), + }) + }; + } + + Ok(Self { + id: AmiId(extract!(image_id)?), + tags: extract!(tags)?.try_into()?, + creation_date: RawImageCreationDate(extract!(creation_date)?).try_into()?, + }) + } +} + +#[Tag(translate = manual)] +#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Copy, Clone)] +pub struct Timestamp(DateTime); + +impl Timestamp { + pub const fn new(value: DateTime) -> Self { + Self(value) + } + + pub const fn inner(&self) -> &DateTime { + &self.0 + } +} + +impl fmt::Display for Timestamp { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{}", self.0) + } +} + +impl TryFrom for Timestamp { + type Error = ParseTagValueError; + + fn try_from(value: RawTagValue) -> Result { + Ok(Self( + chrono::NaiveDateTime::parse_from_str(value.as_str(), "%Y-%m-%dT%H:%M:%S") + .map_err(|e| ParseTagValueError::InvalidValue { + value, + message: format!("failed parsing timestamp: {e}"), + }) + .map(|timestamp| timestamp.and_utc())?, + )) + } +} + +impl From for RawTagValue { + fn from(value: Timestamp) -> Self { + Self::new(value.0.format("%Y-%m-%dT%H:%M:%S").to_string()) + } +} + +struct RawImageCreationDate(String); + +impl TryFrom for Timestamp { + type Error = Error; + + fn try_from(value: RawImageCreationDate) -> Result { + Ok(Self( + chrono::NaiveDateTime::parse_from_str(&value.0, "%Y-%m-%dT%H:%M:%S.%.3fZ") + .map_err(|e| Error::InvalidTimestampError { + value: value.0, + message: format!("failed parsing timestamp: {e}"), + }) + .map(|timestamp| timestamp.and_utc())?, + )) + } +} + +#[derive(Debug, Serialize, Deserialize, Clone)] +pub struct Ip(net::IpAddr); + +impl Ip { + pub const fn new(value: net::IpAddr) -> Self { + Self(value) + } + + pub fn into_string(&self) -> String { + self.0.to_string() + } +} + +impl fmt::Display for Ip { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{}", self.0) + } +} + +string_newtype!(EipAllocationId); + +impl EipAllocationId { + pub const fn new(value: String) -> Self { + Self(value) + } + + pub fn as_str(&self) -> &str { + &self.0 + } +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct Eip { + pub allocation_id: EipAllocationId, + pub ip: Ip, + pub associated_instance: Option, +} + +impl TryFrom for Eip { + type Error = Error; + + fn try_from(address: aws_sdk_ec2::types::Address) -> Result { + macro_rules! extract { + ($field:ident) => { + address.$field.ok_or_else(|| Error::UnexpectedNoneValue { + entity: stringify!($field).to_owned(), + }) + }; + } + + Ok(Self { + ip: Ip(extract!(public_ip)?.parse()?), + associated_instance: address.instance_id.map(InstanceId), + allocation_id: EipAllocationId(extract!(allocation_id)?), + }) + } +} + +impl Eip { + pub async fn attach_to_instance( + &self, + client: &RegionClient, + new_instance: &Instance, + ) -> Result<(), Error> { + let _association_id = client + .main + .ec2 + .associate_address() + .allocation_id(self.allocation_id.as_str()) + .instance_id(new_instance.instance_id().as_str()) + .send() + .await?; + + Ok(()) + } + + pub async fn set_tags(&self, client: &RegionClient, tags: TagList) -> Result<(), Error> { + let _output = client + .main + .ec2 + .delete_tags() + .resources(self.allocation_id.as_str()) + .send() + .await?; + + let _output = client + .main + .ec2 + .create_tags() + .resources(self.allocation_id.as_str()) + .set_tags(Some(tags.into())) + .send() + .await?; + + Ok(()) + } +} + +string_newtype!(CloudfrontDistributionId); + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "lowercase")] +pub enum CloudfrontDistributionStatus { + Deployed, + Other(String), +} + +impl fmt::Display for CloudfrontDistributionStatus { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!( + f, + "{}", + match *self { + Self::Deployed => "deployed", + Self::Other(ref s) => &s, + } + ) + } +} + +impl From for CloudfrontDistributionStatus { + fn from(value: String) -> Self { + match value.as_str() { + "Deployed" => Self::Deployed, + _ => Self::Other(value), + } + } +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct EfsId(String); + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct Efs { + id: EfsId, + region: Region, +} + +impl Efs { + pub fn fs_dns_name(&self) -> String { + format!("{}.efs.{}.amazonaws.com", self.id.0, self.region.as_str()) + } +} + +impl TryFrom<(aws_sdk_efs::types::FileSystemDescription, Region)> for Efs { + type Error = Error; + + fn try_from( + (efs, region): (aws_sdk_efs::types::FileSystemDescription, Region), + ) -> Result { + Ok(Self { + id: EfsId(efs.file_system_id), + region, + }) + } +} + +string_newtype!(CloudfrontDistributionDomain); + +impl From for CloudfrontDistributionDomain { + fn from(value: String) -> Self { + Self(value) + } +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct CloudfrontOrigin { + id: CloudfrontOriginId, + domain: CloudfrontOriginDomain, +} + +impl CloudfrontOrigin { + pub const fn id(&self) -> &CloudfrontOriginId { + &self.id + } +} + +string_newtype!(CloudfrontOriginId); +string_newtype!(CloudfrontOriginDomain); + +impl PartialEq for CloudfrontOriginId { + fn eq(&self, other: &str) -> bool { + self.0 == other + } +} + +impl CloudfrontOriginDomain { + pub fn as_str(&self) -> &str { + &self.0 + } +} + +impl From for CloudfrontOriginDomain { + fn from(value: String) -> Self { + Self(value) + } +} + +impl From for CloudfrontOrigin { + fn from(value: aws_sdk_cloudfront::types::Origin) -> Self { + Self { + id: CloudfrontOriginId(value.id), + domain: value.domain_name.into(), + } + } +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct CloudfrontDistribution { + pub id: CloudfrontDistributionId, + pub status: CloudfrontDistributionStatus, + pub domain: CloudfrontDistributionDomain, + pub origins: Vec, +} + +impl TryFrom for CloudfrontDistribution { + type Error = Error; + + fn try_from( + distribution: aws_sdk_cloudfront::types::DistributionSummary, + ) -> Result { + Ok(Self { + id: CloudfrontDistributionId(distribution.id), + status: distribution.status.into(), + domain: distribution.domain_name.into(), + origins: distribution.origins.map_or_else(Vec::new, |origins| { + origins.items.into_iter().map(Into::into).collect() + }), + }) + } +} + +impl CloudfrontDistribution { + pub fn origins(&self) -> &[CloudfrontOrigin] { + &self.origins + } + + pub const fn domain(&self) -> &CloudfrontDistributionDomain { + &self.domain + } + + pub const fn status(&self) -> &CloudfrontDistributionStatus { + &self.status + } +} + +#[derive(Clone)] +pub struct ProfileName(String); + +impl ProfileName { + pub const fn new(value: String) -> Self { + Self(value) + } +} + +#[derive(Clone)] +pub struct ProfileConfig { + pub profile_name_main: ProfileName, + pub profile_name_cdn: ProfileName, +} + +pub async fn load_sdk_clients( + regions: [Region; C], + profile_config: ProfileConfig, +) -> Vec { + let mut region_clients = vec![]; + + for region in regions { + let base_config = || { + aws_config::ConfigLoader::default() + .retry_config(RetryConfig::standard()) + .stalled_stream_protection( + aws_sdk_ec2::config::StalledStreamProtectionConfig::enabled() + .grace_period(Duration::from_secs(5)) + .build(), + ) + .behavior_version(aws_config::BehaviorVersion::latest()) + }; + + let config = base_config() + .profile_name(&profile_config.profile_name_main.0) + .region(region.name()) + .load() + .await; + + let config_cdn = base_config() + .profile_name(&profile_config.profile_name_cdn.0) + .region(region.name()) + .load() + .await; + + // Cloudformation needs always be run in us-east-1 + let config_cloudformation = base_config() + .profile_name(&profile_config.profile_name_cdn.0) + .region(Region::UsEast1.as_str()) + .load() + .await; + + let ec2_client = aws_sdk_ec2::Client::new(&config); + let cloudfront_client = aws_sdk_cloudfront::Client::new(&config_cdn); + let efs_client = aws_sdk_efs::Client::new(&config); + let route53_client = aws_sdk_route53::Client::new(&config); + let cloudformation_client = aws_sdk_cloudformation::Client::new(&config_cloudformation); + + region_clients.push(RegionClient { + region, + main: RegionClientMain { + ec2: ec2_client, + efs: efs_client, + route53: route53_client, + }, + cdn: RegionClientCdn { + cloudfront: cloudfront_client, + cloudformation: cloudformation_client, + }, + }); + } + + region_clients +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct Account { + id: String, +} + +impl Account { + pub const fn new(id: String) -> Self { + Self { id } + } + + pub fn id(&self) -> &str { + &self.id + } +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct HostedZoneId(String); + +impl HostedZoneId { + pub const fn new(value: String) -> Self { + Self(value) + } + + pub fn as_str(&self) -> &str { + &self.0 + } +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct Route53Zone { + hosted_zone_id: HostedZoneId, + name: String, +} + +impl Route53Zone { + pub async fn find_by_name(client: &RegionClient, name: &str) -> Result, Error> { + Ok(client + .main + .route53 + .list_hosted_zones() + .into_paginator() + .items() + .send() + .try_collect() + .await? + .into_iter() + .filter(|zone| zone.name == name) + .map(Into::into) + .next()) + } + + pub const fn new(name: String, hosted_zone_id: HostedZoneId) -> Self { + Self { + hosted_zone_id, + name, + } + } +} + +impl From for Route53Zone { + fn from(zone: aws_sdk_route53::types::HostedZone) -> Self { + Self { + hosted_zone_id: HostedZoneId(zone.id), + name: zone.name, + } + } +} + +pub struct NewEc2Config<'a> { + pub ami: &'a Ami, + pub instance_type: &'a InstanceType, + pub security_group: &'a SecurityGroup, + pub instance_profile_name: &'a InstanceProfileName, + pub instance_keypair_name: &'a InstanceKeypairName, + pub subnet_id: &'a SubnetId, + pub user_data: &'a str, + pub tags: &'a TagList, +} + +pub async fn start_ec2_instance<'a>( + client: &RegionClient, + ami: &'a Ami, + instance_type: &'a InstanceType, + security_group: &'a SecurityGroup, + instance_profile_name: &'a InstanceProfileName, + instance_keypair_name: &'a InstanceKeypairName, + subnet_id: &'a SubnetId, + user_data: &'a str, + tags: &'a TagList, +) -> Result { + Instance::try_from_aws( + client + .main + .ec2 + .run_instances() + .image_id(ami.id.as_str()) + .instance_type(instance_type.clone().into_inner()) + .key_name(instance_keypair_name.as_str()) + .min_count(1) + .max_count(1) + .security_group_ids(security_group.id.as_str()) + .subnet_id(subnet_id.as_str()) + .user_data(user_data) + .tag_specifications( + aws_sdk_ec2::types::TagSpecification::builder() + .resource_type(aws_sdk_ec2::types::ResourceType::Instance) + .set_tags(Some(tags.clone().into())) + .build(), + ) + .metadata_options( + aws_sdk_ec2::types::InstanceMetadataOptionsRequest::builder() + .http_tokens(aws_sdk_ec2::types::HttpTokensState::Optional) + .http_endpoint(aws_sdk_ec2::types::InstanceMetadataEndpointState::Enabled) + .instance_metadata_tags(aws_sdk_ec2::types::InstanceMetadataTagsState::Enabled) + .build(), + ) + .disable_api_termination(true) + .iam_instance_profile( + aws_sdk_ec2::types::IamInstanceProfileSpecification::builder() + .name(instance_profile_name.as_str()) + .build(), + ) + .send() + .await? + .instances + .ok_or(Error::UnexpectedNoneValue { + entity: "RunInstancesOutput.instances".to_owned(), + })? + .pop() + .ok_or(Error::RunInstancesEmptyResponse)?, + ) +} + +pub async fn create_cloudformation_stack( + client: &RegionClient, + name: &str, + template: &str, + parameters: &CloudformationParameters, + tags: &TagList, +) -> Result<(), Error> { + let _create_stack_output = client + .cdn + .cloudformation + .create_stack() + .stack_name(name) + .template_body(template) + .set_parameters(Some( + parameters + .0 + .iter() + .map(|param| { + aws_sdk_cloudformation::types::Parameter::builder() + .parameter_key(param.key.as_str()) + .parameter_value(param.value.as_str()) + .build() + }) + .collect(), + )) + .disable_rollback(true) + .capabilities(aws_sdk_cloudformation::types::Capability::CapabilityAutoExpand) + .set_tags(Some(tags.clone().into())) + .send() + .await?; + + Ok(()) +} + +pub struct CloudformationParameter { + key: String, + value: String, +} + +impl CloudformationParameter { + pub const fn new(key: String, value: String) -> Self { + Self { key, value } + } +} + +pub struct CloudformationParameters(Vec); + +impl CloudformationParameters { + pub const fn new(value: Vec) -> Self { + Self(value) + } +} + +#[expect( + clippy::missing_panics_doc, + reason = "only expect() on builder instances" +)] +pub async fn create_route53_record( + client: &RegionClient, + eip: &Eip, + route53_zone: &Route53Zone, + fqdn: &str, +) -> Result<(), Error> { + let _change_info = client + .main + .route53 + .change_resource_record_sets() + .hosted_zone_id(route53_zone.hosted_zone_id.as_str()) + .change_batch( + aws_sdk_route53::types::ChangeBatch::builder() + .changes( + aws_sdk_route53::types::Change::builder() + .action(aws_sdk_route53::types::ChangeAction::Create) + .resource_record_set( + aws_sdk_route53::types::ResourceRecordSet::builder() + .name(fqdn) + .r#type(aws_sdk_route53::types::RrType::A) + .ttl(600) + .resource_records( + aws_sdk_route53::types::ResourceRecord::builder() + .value(eip.ip.to_string()) + .build() + .expect("builder has missing fields"), + ) + .build() + .expect("builder has missing fields"), + ) + .build() + .expect("builder has missing fields"), + ) + .build() + .expect("builder has missing fields"), + ) + .send() + .await?; + + Ok(()) +} + +pub async fn find_efs(client: &RegionClient, tag: &RawTag) -> Result, Error> { + let mut found = client + .main + .efs + .describe_file_systems() + .into_paginator() + .items() + .send() + .try_collect() + .await? + .into_iter() + .filter(|fs| fs.tags.iter().any(|t| t == tag)) + .map(|fs| (fs, client.region).try_into()) + .collect::, Error>>()?; + + match (found.len(), found.pop()) { + (0, _) => Ok(None), + (1, Some(found)) => Ok(Some(found)), + _ => Err(Error::MultipleMatches { + entity: "efs".to_owned(), + }), + } +} diff --git a/src/tags/README.md b/src/tags/README.md new file mode 100644 index 0000000..04bb0d4 --- /dev/null +++ b/src/tags/README.md @@ -0,0 +1,72 @@ +Type-safe operations on AWS tags. + +# Overview + +This basic data structure of this module is the [`TagList`] struct. It contains +a list of untyped AWS tags. It implements `TryFrom` and `Into` for the relevant +`Tag` types in the `aws_sdk_*` crates. In itself, that is not too interesting, +as the tag values are still just `String`. + +To get typed tags, there is a [`macro@Tags`] macro. Applied to a struct, it adds +methods to create a struct instance for an instance [`TagList`], and turn a +struct instance back into a [`TagList`]: + +```rust +use aws::tags::{Tags, TagList, RawTag}; + +#[Tags] +struct MyTags { + tag1: String, + tag2: bool, + tag3: Option, +} + +let tags = TagList::from_vec(vec![ + RawTag::new("tag1".to_owned(), "foo".to_owned()), + RawTag::new("tag2".to_owned(), "true".to_owned()), +]); + +let parsed = MyTags::from_tags(tags).unwrap(); + +assert!(parsed.tag1 == "foo"); +assert!(parsed.tag2); +assert!(parsed.tag3.is_none()); +``` + +## Using custom tag types + +By default, encoding and decoding of tags is supported for `String` and `bool` +values. + +- `String` is encoded as-is +- `bool` is encoded as `true` and `false` + +In case you have your own type `T` you want to encode in a tag, there are two +strategies: + +- `serde`, which requires `T` to implement `Serialize` and `Deserialize`. +- `manual`, which requires `T` to impelemnt two traits: + - `impl TryFrom for T`: How to (fallibly) create a `T` from the + value of an tag + - `impl From for RawTagValue`: How to turn `T` back into the value of a + tag. This cannot fail. + +There is a [`macro@Tag`] macro that selects the strategy, which can then be used +in a struct that is using `#[Tags]`: + +```rust +use aws::tags::{Tag, Tags}; +use serde::{Serialize, Deserialize}; + +#[Tag(translate = serde)] +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +struct MyTag { + foo: String, + bar: bool, +} + +#[Tags] +struct MyTags { + foo: MyTag, +} +``` diff --git a/src/tags/error.rs b/src/tags/error.rs new file mode 100644 index 0000000..0a4d2fa --- /dev/null +++ b/src/tags/error.rs @@ -0,0 +1,127 @@ +#![expect(clippy::module_name_repetitions, reason = "error prefix is necessary")] + +use std::{convert::Infallible, fmt}; + +use super::{RawTagValue, TagKey}; + +#[derive(Debug, Clone)] +pub enum ParseTagAwsError { + AwsKeyNone, + AwsValueNone { key: TagKey }, +} + +impl std::error::Error for ParseTagAwsError {} + +impl fmt::Display for ParseTagAwsError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match *self { + Self::AwsKeyNone => write!(f, "aws responded with `None` value for tag key"), + Self::AwsValueNone { ref key } => write!( + f, + "aws responded with `None` value for tag value of tag \"{key}\"" + ), + } + } +} + +#[derive(Debug, Clone)] +pub enum ParseTagValueError { + /// A generic error for type conversions of a tag value to some type `T` + InvalidValue { + value: RawTagValue, + message: String, + }, + /// like `InvalidValue`, but specific for `bool` + InvalidBoolValue { + value: RawTagValue, + }, + Aws(ParseTagAwsError), +} + +impl std::error::Error for ParseTagValueError {} + +impl fmt::Display for ParseTagValueError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match *self { + Self::InvalidBoolValue { ref value } => { + write!(f, "invalid tag bool value \"{value}\"") + } + Self::InvalidValue { + ref value, + ref message, + } => write!(f, "invalid tag value \"{value}\": {message}"), + Self::Aws(ref inner) => write!(f, "aws error: {inner}"), + } + } +} + +impl From for ParseTagValueError { + fn from(_value: Infallible) -> Self { + unreachable!() + } +} + +#[derive(Debug, Clone)] +/// Like [`ParseTagValueError`], but contains potential additional information about the +/// tag *key*. +pub enum ParseTagError { + InvalidTagValue { + key: TagKey, + inner: ParseTagValueError, + }, + Aws(ParseTagAwsError), +} + +impl std::error::Error for ParseTagError {} + +impl fmt::Display for ParseTagError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match *self { + Self::Aws(ref inner) => write!(f, "aws error: {inner}"), + Self::InvalidTagValue { ref key, ref inner } => { + write!(f, "failed parsing tag \"{key}\": {inner}") + } + } + } +} + +/// this is required because `String` can be the inner value of a `Tag`, but is also the input +/// to the `parse()` function. `try_into()` from `String` to `String` returns `Infallible` as +/// the `Err` type. +impl From for ParseTagError { + fn from(_value: Infallible) -> Self { + unreachable!() + } +} + +impl From for ParseTagError { + fn from(value: ParseTagAwsError) -> Self { + Self::Aws(value) + } +} + +#[derive(Debug, Clone)] +/// Errors that can happen when parsing a set of tags. +pub enum ParseTagsError { + /// A required tag was not found + TagNotFound { key: TagKey }, + /// A single tag failed to parse + ParseTag(ParseTagError), +} + +impl std::error::Error for ParseTagsError {} + +impl fmt::Display for ParseTagsError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match *self { + Self::TagNotFound { ref key } => write!(f, "tag {key} not found in input"), + Self::ParseTag(ref err) => write!(f, "failed parsing tag: {err}"), + } + } +} + +impl From for ParseTagsError { + fn from(value: ParseTagError) -> Self { + Self::ParseTag(value) + } +} diff --git a/src/tags/helpers.rs b/src/tags/helpers.rs new file mode 100644 index 0000000..2cf6ff2 --- /dev/null +++ b/src/tags/helpers.rs @@ -0,0 +1,49 @@ +macro_rules! impl_string_wrapper { + ($name:ident) => { + impl $name { + pub const fn new(value: String) -> Self { + Self(value) + } + + pub fn as_str(&self) -> &str { + &self.0 + } + + pub fn into_string(self) -> String { + self.0 + } + } + + impl From for $name { + fn from(value: String) -> Self { + Self::new(value) + } + } + + impl From<$name> for String { + fn from(value: $name) -> Self { + value.into_string() + } + } + + impl fmt::Display for $name { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{}", self.0) + } + } + + impl PartialEq for $name { + fn eq(&self, other: &str) -> bool { + self.as_str() == other + } + } + + impl PartialEq for $name { + fn eq(&self, other: &String) -> bool { + self.as_str() == other + } + } + }; +} + +pub(crate) use impl_string_wrapper; diff --git a/src/tags/mod.rs b/src/tags/mod.rs new file mode 100644 index 0000000..259dd71 --- /dev/null +++ b/src/tags/mod.rs @@ -0,0 +1,407 @@ +#![doc = include_str!("README.md")] +use std::fmt::{self, Debug}; + +use serde::{de::DeserializeOwned, Deserialize, Serialize}; + +mod error; +mod helpers; +mod predefined_types; +mod svc; + +pub use aws_macros::{Tag, Tags}; +pub use error::{ParseTagAwsError, ParseTagError, ParseTagValueError, ParseTagsError}; + +#[derive(Debug, PartialEq, Eq)] +struct InnerTagValue(T) +where + T: Debug + Clone + PartialEq + Eq + Send; + +impl From for InnerTagValue +where + T: Debug + Clone + PartialEq + Eq + Send, +{ + fn from(value: T) -> Self { + Self(value) + } +} + +impl From> for String +where + T: Debug + Clone + PartialEq + Eq + Into + Send, +{ + fn from(value: InnerTagValue) -> Self { + value.0.into().0 + } +} + +impl PartialEq for InnerTagValue +where + T: Debug + Clone + PartialEq + Eq + Into + Send, +{ + fn eq(&self, other: &T) -> bool { + &self.0 == other + } +} + +#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)] +pub struct RawTagValue(String); +helpers::impl_string_wrapper!(RawTagValue); + +pub struct TranslateSerde; +pub struct TranslateManual; + +pub trait Translator { + type Error; + + fn from_raw_tag(value: RawTagValue) -> Result; + fn into_raw_tag(value: T) -> RawTagValue; +} + +pub trait TranslatableSerde: Serialize + DeserializeOwned {} +pub trait TranslatableManual: + TryFrom> + Into +{ +} + +pub trait TagValue { + type Error; + type Translator: Translator; + + fn from_raw_tag(value: RawTagValue) -> Result { + Self::Translator::from_raw_tag(value) + } + + fn into_raw_tag(value: V) -> RawTagValue { + Self::Translator::into_raw_tag(value) + } +} + +impl Translator for TranslateSerde +where + T: TranslatableSerde, +{ + type Error = ParseTagValueError; + + fn from_raw_tag(value: RawTagValue) -> Result { + serde_json::from_str::(value.as_str()).map_err(|e| ParseTagValueError::InvalidValue { + value, + message: e.to_string(), + }) + } + + fn into_raw_tag(value: T) -> RawTagValue { + RawTagValue(serde_json::to_string(&value).expect("serialization always succeeds")) + } +} + +impl Translator for TranslateManual +where + T: TranslatableManual, +{ + type Error = ParseTagValueError; + + fn from_raw_tag(value: RawTagValue) -> Result { + match value.clone().try_into() { + Ok(r) => Ok(r), + Err(e) => Err(ParseTagValueError::InvalidValue { + value, + message: { + let e: ParseTagValueError = e.into(); + e.to_string() + }, + }), + } + } + + fn into_raw_tag(value: T) -> RawTagValue { + value.into() + } +} + +#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] +pub struct RawTag { + key: TagKey, + value: RawTagValue, +} + +impl RawTag { + pub fn new(key: impl Into, value: impl Into) -> Self { + Self { + key: key.into(), + value: value.into(), + } + } + + pub const fn key(&self) -> &TagKey { + &self.key + } + + pub const fn value(&self) -> &RawTagValue { + &self.value + } +} + +impl From> for RawTag +where + T: Debug + Clone + PartialEq + Eq + Send, + T: TagValue, + InnerTagValue: fmt::Display + Into, +{ + fn from(tag: Tag) -> Self { + Self { + key: tag.key, + value: tag.value.into(), + } + } +} + +#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] +pub struct TagKey(String); +helpers::impl_string_wrapper!(TagKey); + +/// A tag generic over it's containing value type. +/// +/// There are two ways to construct a `Tag`: +/// +/// * You already have a `T`: Just use [`new()`](Self::new()) +/// ```rust +/// use aws::tags::Tag; +/// +/// let tag = Tag::::new("foo".to_owned(), true); +/// ``` +/// +/// * You have something that may be able to be turned into a [`TagValue`]. In that +/// case, either use [`parse()`](Self::parse()) or the `TryInto` implementation. +/// [`parse()`](Self::parse()) accepts an `impl Into`, which is implemented +/// for `String`: +/// +/// ```rust +/// use aws::tags::Tag; +/// +/// let tag = Tag::::parse("foo".to_owned(), "true".to_owned()).unwrap(); +/// ``` +/// +/// Both the `TryInto` implementation and [`parse()`](Self::parse()) may return a +/// [`ParseTagValueError`] that contains more information about the parse failure. +#[derive(Debug, PartialEq, Eq)] +pub struct Tag +where + T: Debug + Clone + PartialEq + Eq + Send, + T: TagValue, +{ + key: TagKey, + value: InnerTagValue, +} + +impl TryFrom for Tag +where + T: Clone + PartialEq + Eq + Debug + Send, + T: TagValue, +{ + type Error = ParseTagValueError; + + fn try_from(tag: RawTag) -> Result { + Self::parse(tag.key, tag.value) + } +} + +impl Tag +where + T: Debug + Clone + PartialEq + Eq + Send, + T: TagValue, +{ + pub fn new(key: impl Into, value: T) -> Self { + Self { + key: key.into(), + value: InnerTagValue(value), + } + } + + pub fn parse( + key: impl Into, + value: impl Into, + ) -> Result + where + T: TagValue, + { + Ok(Self { + key: key.into(), + value: { + InnerTagValue(>::from_raw_tag(RawTagValue::new( + value.into(), + ))?) + }, + }) + } +} + +impl Tag +where + T: Debug + Clone + PartialEq + Eq + Send, + T: TagValue, +{ + fn into_parts(self) -> (TagKey, InnerTagValue) { + (self.key, self.value) + } + + pub const fn key(&self) -> &TagKey { + &self.key + } + + pub const fn value(&self) -> &T { + &self.value.0 + } +} + +#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq)] +pub struct TagList(Vec); + +impl TagList { + pub const fn new() -> Self { + Self(Vec::new()) + } + + pub fn push(&mut self, tag: RawTag) { + self.0.push(tag); + } + + pub fn extend(&mut self, tags: Vec) { + self.0.extend(tags); + } + + pub fn join(&mut self, other: Self) { + self.0.extend(other.0); + } + + pub const fn from_vec(value: Vec) -> Self { + Self(value) + } + + pub fn get(&self, key: impl Into) -> Option<&RawTag> { + let key: TagKey = key.into(); + self.0.iter().find(|tag| tag.key == key) + } + + pub fn into_vec(self) -> Vec { + self.0 + } + + pub fn as_slice(&self) -> &[RawTag] { + &self.0 + } +} + +#[cfg(test)] +mod tests { + use serde::{Deserialize, Serialize}; + + use super::*; + + #[Tag(translate = manual)] + #[derive(Debug, Clone, PartialEq, Eq)] + enum MyTag { + A, + B, + } + + #[Tag(translate = serde)] + #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] + struct MyStructTag { + foo: String, + bar: bool, + } + + impl TryFrom for MyTag { + type Error = ParseTagValueError; + + fn try_from(value: RawTagValue) -> Result { + match value.as_str() { + "A" => Ok(Self::A), + "B" => Ok(Self::B), + _ => Err(ParseTagValueError::InvalidValue { + value, + message: "could not match to MyTag enum".to_owned(), + }), + } + } + } + + impl From for RawTagValue { + fn from(value: MyTag) -> Self { + match value { + MyTag::A => Self("A".to_owned()), + MyTag::B => Self("B".to_owned()), + } + } + } + + #[test] + fn use_tag_directly() { + let key = "Name"; + + let tag1 = Tag::::new(key.to_owned(), true); + assert!(*tag1.value()); + + let tag2 = Tag::::parse(key.to_owned(), "true".to_owned()).unwrap(); + assert!(*tag2.value()); + } + + #[test] + fn use_attribute_macro() { + #[Tags] + struct MyWrappedTags { + tag1: String, + tag2: bool, + tag3: Option, + tag4: Option, + #[tag(key = "myname")] + tag5: MyTag, + #[tag(key = "anothername")] + tag6: Option, + tag7: Option, + tag8: MyStructTag, + tag9: Option, + } + + let tags = TagList::from_vec(vec![ + RawTag::new("tag1".to_owned(), "false".to_owned()), + RawTag::new("tag2".to_owned(), "true".to_owned()), + RawTag::new("tag3".to_owned(), "false".to_owned()), + RawTag::new("myname".to_owned(), "A".to_owned()), + RawTag::new("anothername".to_owned(), "B".to_owned()), + RawTag::new("tag8".to_owned(), r#"{"foo":"hi","bar":false}"#.to_owned()), + ]); + + let tags = MyWrappedTags::from_tags(tags).unwrap(); + + assert!(tags.tag1 == "false"); + assert!(tags.tag2); + assert!(tags.tag3 == Some(false)); + assert!(tags.tag4.is_none()); + assert!(tags.tag5 == MyTag::A); + assert!(tags.tag6 == Some(MyTag::B)); + assert!(tags.tag7.is_none()); + assert!( + tags.tag8 + == MyStructTag { + foo: "hi".to_owned(), + bar: false + } + ); + assert!(tags.tag9.is_none()); + + let into_tags = tags.into_tags(); + + assert_eq!( + into_tags, + TagList::from_vec(vec![ + RawTag::new("tag1".to_owned(), "false".to_owned()), + RawTag::new("tag2".to_owned(), "true".to_owned()), + RawTag::new("tag3".to_owned(), "false".to_owned()), + RawTag::new("myname".to_owned(), "A".to_owned()), + RawTag::new("anothername".to_owned(), "B".to_owned()), + RawTag::new("tag8".to_owned(), r#"{"foo":"hi","bar":false}"#.to_owned(),), + ]) + ); + } +} diff --git a/src/tags/predefined_types.rs b/src/tags/predefined_types.rs new file mode 100644 index 0000000..b1907b6 --- /dev/null +++ b/src/tags/predefined_types.rs @@ -0,0 +1,23 @@ +use super::{ + ParseTagValueError, TagValue, TranslatableManual, TranslatableSerde, TranslateManual, + TranslateSerde, +}; + +// Bools can just be handled by serde. +impl TranslatableSerde for bool {} + +impl TagValue for bool { + type Error = ParseTagValueError; + type Translator = TranslateSerde; +} + +// Due to quoting, we cannot use serde here. It would produce quoted +// strings. Instead, we just serialize/deserialize strings as-is. +// Note that we get the `String` conversion functions for free via the +// `impl_string_wrapper` macro application on `RawTagValue`. +impl TranslatableManual for String {} + +impl TagValue for String { + type Error = ParseTagValueError; + type Translator = TranslateManual; +} diff --git a/src/tags/svc.rs b/src/tags/svc.rs new file mode 100644 index 0000000..481eea6 --- /dev/null +++ b/src/tags/svc.rs @@ -0,0 +1,233 @@ +mod ec2 { + use std::fmt::Debug; + + use super::super::{ + error::ParseTagAwsError, ParseTagError, ParseTagsError, RawTag, RawTagValue, Tag, TagKey, + TagList, TagValue, + }; + + impl From> for aws_sdk_ec2::types::Tag + where + T: Debug + Clone + PartialEq + Eq + Into + Send, + T: TagValue, + { + fn from(tag: Tag) -> Self { + let (key, value) = tag.into_parts(); + Self::builder().key(key).value(value.0).build() + } + } + + impl From for aws_sdk_ec2::types::Tag { + fn from(tag: RawTag) -> Self { + Self::builder().key(tag.key).value(tag.value.0).build() + } + } + + impl TryFrom> for TagList { + type Error = ParseTagsError; + + fn try_from(list: Vec) -> Result { + Ok(Self( + list.into_iter() + .map(TryInto::try_into) + .collect::, ParseTagError>>()?, + )) + } + } + + impl From for Vec { + fn from(tags: TagList) -> Self { + tags.0.into_iter().map(Into::into).collect() + } + } + + impl From for Vec { + fn from(tags: TagList) -> Self { + tags.0 + .into_iter() + .map(|tag| { + aws_sdk_ec2::types::Filter::builder() + .name(format!("tag:{}", tag.key)) + .values(tag.value) + .build() + }) + .collect() + } + } + + impl TryFrom for RawTag { + type Error = ParseTagError; + + fn try_from(tag: aws_sdk_ec2::types::Tag) -> Result { + let key = TagKey(tag.key.ok_or(ParseTagAwsError::AwsKeyNone)?); + let value = RawTagValue( + tag.value + .ok_or_else(|| ParseTagAwsError::AwsValueNone { key: key.clone() })?, + ); + Ok(Self { key, value }) + } + } + + impl PartialEq for RawTag { + fn eq(&self, other: &aws_sdk_ec2::types::Tag) -> bool { + Some(&self.key.0) == other.key.as_ref() && Some(&self.value.0) == other.value.as_ref() + } + } + + impl PartialEq for aws_sdk_ec2::types::Tag { + fn eq(&self, other: &RawTag) -> bool { + other.eq(self) + } + } + + impl From for aws_sdk_ec2::types::TagSpecification { + fn from(value: TagList) -> Self { + Self::builder() + .resource_type(aws_sdk_ec2::types::ResourceType::Instance) + .set_tags(Some(value.into())) + .build() + } + } +} + +mod cloudformation { + use std::fmt::Debug; + + use super::super::{ + error::ParseTagAwsError, ParseTagError, ParseTagsError, RawTag, RawTagValue, Tag, TagKey, + TagList, TagValue, + }; + + impl From> for aws_sdk_cloudformation::types::Tag + where + T: Debug + Clone + PartialEq + Eq + Into + Send, + T: TagValue, + { + fn from(tag: Tag) -> Self { + let (key, value) = tag.into_parts(); + Self::builder().key(key).value(value.0).build() + } + } + + impl From for aws_sdk_cloudformation::types::Tag { + fn from(tag: RawTag) -> Self { + Self::builder().key(tag.key).value(tag.value.0).build() + } + } + + impl TryFrom> for TagList { + type Error = ParseTagsError; + + fn try_from(list: Vec) -> Result { + Ok(Self( + list.into_iter() + .map(TryInto::try_into) + .collect::, ParseTagError>>()?, + )) + } + } + + impl From for Vec { + fn from(tags: TagList) -> Self { + tags.0.into_iter().map(Into::into).collect() + } + } + + impl TryFrom for RawTag { + type Error = ParseTagError; + + fn try_from(tag: aws_sdk_cloudformation::types::Tag) -> Result { + let key = TagKey(tag.key.ok_or(ParseTagAwsError::AwsKeyNone)?); + let value = RawTagValue( + tag.value + .ok_or_else(|| ParseTagAwsError::AwsValueNone { key: key.clone() })?, + ); + Ok(Self { key, value }) + } + } + + impl PartialEq for RawTag { + fn eq(&self, other: &aws_sdk_cloudformation::types::Tag) -> bool { + Some(&self.key.0) == other.key.as_ref() && Some(&self.value.0) == other.value.as_ref() + } + } + + impl PartialEq for aws_sdk_cloudformation::types::Tag { + fn eq(&self, other: &RawTag) -> bool { + other.eq(self) + } + } +} + +mod efs { + use std::fmt::Debug; + + use super::super::{ + ParseTagError, ParseTagsError, RawTag, RawTagValue, Tag, TagKey, TagList, TagValue, + }; + + impl From> for aws_sdk_efs::types::Tag + where + T: Debug + Clone + PartialEq + Eq + Into + Send, + T: TagValue, + { + fn from(tag: Tag) -> Self { + let (key, value) = tag.into_parts(); + Self::builder() + .key(key) + .value(value.0) + .build() + .expect("builder misused") + } + } + + impl From for aws_sdk_efs::types::Tag { + fn from(tag: RawTag) -> Self { + Self::builder() + .key(tag.key) + .value(tag.value.0) + .build() + .expect("builder misused") + } + } + + impl TryFrom> for TagList { + type Error = ParseTagsError; + + fn try_from(list: Vec) -> Result { + Ok(Self( + list.into_iter() + .map(TryInto::try_into) + .collect::, ParseTagError>>()?, + )) + } + } + + impl From for Vec { + fn from(tags: TagList) -> Self { + tags.0.into_iter().map(Into::into).collect() + } + } + + impl TryFrom for RawTag { + type Error = ParseTagError; + + fn try_from(tag: aws_sdk_efs::types::Tag) -> Result { + let key = TagKey(tag.key); + let value = RawTagValue(tag.value); + Ok(Self { key, value }) + } + } + + impl PartialEq for RawTag { + fn eq(&self, other: &aws_sdk_efs::types::Tag) -> bool { + self.key.0 == other.key && self.value.0 == other.value + } + } + + impl PartialEq for aws_sdk_efs::types::Tag { + fn eq(&self, other: &RawTag) -> bool { + other.eq(self) + } + } +}