Page MenuHomePhorge

D10258.1767449582.diff
No OneTemporary

Size
20 KB
Referenced Files
None
Subscribers
None

D10258.1767449582.diff

diff --git a/services/backup/Cargo.toml b/services/backup/Cargo.toml
--- a/services/backup/Cargo.toml
+++ b/services/backup/Cargo.toml
@@ -17,6 +17,7 @@
comm-lib = { path = "../../shared/comm-lib", features = [
"http",
"blob-client",
+ "aws",
] }
once_cell = "1.17"
tokio = { version = "1.24", features = ["rt-multi-thread", "macros"] }
diff --git a/services/blob/Cargo.toml b/services/blob/Cargo.toml
--- a/services/blob/Cargo.toml
+++ b/services/blob/Cargo.toml
@@ -16,7 +16,7 @@
aws-sdk-s3 = "0.27"
chrono = "0.4.31"
clap = { version = "4.0", features = ["derive", "env"] }
-comm-lib = { path = "../../shared/comm-lib", features = ["http"] }
+comm-lib = { path = "../../shared/comm-lib", features = ["http", "aws"] }
derive_more = "0.99"
http = "0.2"
once_cell = "1.17"
diff --git a/services/commtest/Cargo.lock b/services/commtest/Cargo.lock
--- a/services/commtest/Cargo.lock
+++ b/services/commtest/Cargo.lock
@@ -97,350 +97,6 @@
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
-[[package]]
-name = "aws-config"
-version = "0.55.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bcdcf0d683fe9c23d32cf5b53c9918ea0a500375a9fb20109802552658e576c9"
-dependencies = [
- "aws-credential-types",
- "aws-http",
- "aws-sdk-sso",
- "aws-sdk-sts",
- "aws-smithy-async",
- "aws-smithy-client",
- "aws-smithy-http",
- "aws-smithy-http-tower",
- "aws-smithy-json",
- "aws-smithy-types",
- "aws-types",
- "bytes",
- "fastrand 1.9.0",
- "hex",
- "http",
- "hyper",
- "ring",
- "time",
- "tokio",
- "tower",
- "tracing",
- "zeroize",
-]
-
-[[package]]
-name = "aws-credential-types"
-version = "0.55.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1fcdb2f7acbc076ff5ad05e7864bdb191ca70a6fd07668dc3a1a8bcd051de5ae"
-dependencies = [
- "aws-smithy-async",
- "aws-smithy-types",
- "fastrand 1.9.0",
- "tokio",
- "tracing",
- "zeroize",
-]
-
-[[package]]
-name = "aws-endpoint"
-version = "0.55.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8cce1c41a6cfaa726adee9ebb9a56fcd2bbfd8be49fd8a04c5e20fd968330b04"
-dependencies = [
- "aws-smithy-http",
- "aws-smithy-types",
- "aws-types",
- "http",
- "regex",
- "tracing",
-]
-
-[[package]]
-name = "aws-http"
-version = "0.55.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "aadbc44e7a8f3e71c8b374e03ecd972869eb91dd2bc89ed018954a52ba84bc44"
-dependencies = [
- "aws-credential-types",
- "aws-smithy-http",
- "aws-smithy-types",
- "aws-types",
- "bytes",
- "http",
- "http-body",
- "lazy_static",
- "percent-encoding",
- "pin-project-lite",
- "tracing",
-]
-
-[[package]]
-name = "aws-sdk-dynamodb"
-version = "0.27.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "67fb64867fe098cffee7e34352b01bbfa2beb3aa1b2ff0e0a7bf9ff293557852"
-dependencies = [
- "aws-credential-types",
- "aws-endpoint",
- "aws-http",
- "aws-sig-auth",
- "aws-smithy-async",
- "aws-smithy-client",
- "aws-smithy-http",
- "aws-smithy-http-tower",
- "aws-smithy-json",
- "aws-smithy-types",
- "aws-types",
- "bytes",
- "fastrand 1.9.0",
- "http",
- "regex",
- "tokio-stream",
- "tower",
- "tracing",
-]
-
-[[package]]
-name = "aws-sdk-secretsmanager"
-version = "0.27.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "502ccd2a5469223f03116ed1ef8d310bfe3caa0e8398b968439cd8e76e4ae91c"
-dependencies = [
- "aws-credential-types",
- "aws-endpoint",
- "aws-http",
- "aws-sig-auth",
- "aws-smithy-async",
- "aws-smithy-client",
- "aws-smithy-http",
- "aws-smithy-http-tower",
- "aws-smithy-json",
- "aws-smithy-types",
- "aws-types",
- "bytes",
- "fastrand 1.9.0",
- "http",
- "regex",
- "tokio-stream",
- "tower",
- "tracing",
-]
-
-[[package]]
-name = "aws-sdk-sso"
-version = "0.28.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c8b812340d86d4a766b2ca73f740dfd47a97c2dff0c06c8517a16d88241957e4"
-dependencies = [
- "aws-credential-types",
- "aws-endpoint",
- "aws-http",
- "aws-sig-auth",
- "aws-smithy-async",
- "aws-smithy-client",
- "aws-smithy-http",
- "aws-smithy-http-tower",
- "aws-smithy-json",
- "aws-smithy-types",
- "aws-types",
- "bytes",
- "http",
- "regex",
- "tokio-stream",
- "tower",
- "tracing",
-]
-
-[[package]]
-name = "aws-sdk-sts"
-version = "0.28.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "265fac131fbfc188e5c3d96652ea90ecc676a934e3174eaaee523c6cec040b3b"
-dependencies = [
- "aws-credential-types",
- "aws-endpoint",
- "aws-http",
- "aws-sig-auth",
- "aws-smithy-async",
- "aws-smithy-client",
- "aws-smithy-http",
- "aws-smithy-http-tower",
- "aws-smithy-json",
- "aws-smithy-query",
- "aws-smithy-types",
- "aws-smithy-xml",
- "aws-types",
- "bytes",
- "http",
- "regex",
- "tower",
- "tracing",
-]
-
-[[package]]
-name = "aws-sig-auth"
-version = "0.55.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3b94acb10af0c879ecd5c7bdf51cda6679a0a4f4643ce630905a77673bfa3c61"
-dependencies = [
- "aws-credential-types",
- "aws-sigv4",
- "aws-smithy-http",
- "aws-types",
- "http",
- "tracing",
-]
-
-[[package]]
-name = "aws-sigv4"
-version = "0.55.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9d2ce6f507be68e968a33485ced670111d1cbad161ddbbab1e313c03d37d8f4c"
-dependencies = [
- "aws-smithy-http",
- "form_urlencoded",
- "hex",
- "hmac",
- "http",
- "once_cell",
- "percent-encoding",
- "regex",
- "sha2",
- "time",
- "tracing",
-]
-
-[[package]]
-name = "aws-smithy-async"
-version = "0.55.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "13bda3996044c202d75b91afeb11a9afae9db9a721c6a7a427410018e286b880"
-dependencies = [
- "futures-util",
- "pin-project-lite",
- "tokio",
- "tokio-stream",
-]
-
-[[package]]
-name = "aws-smithy-client"
-version = "0.55.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0a86aa6e21e86c4252ad6a0e3e74da9617295d8d6e374d552be7d3059c41cedd"
-dependencies = [
- "aws-smithy-async",
- "aws-smithy-http",
- "aws-smithy-http-tower",
- "aws-smithy-types",
- "bytes",
- "fastrand 1.9.0",
- "http",
- "http-body",
- "hyper",
- "hyper-rustls",
- "lazy_static",
- "pin-project-lite",
- "rustls 0.20.9",
- "tokio",
- "tower",
- "tracing",
-]
-
-[[package]]
-name = "aws-smithy-http"
-version = "0.55.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2b3b693869133551f135e1f2c77cb0b8277d9e3e17feaf2213f735857c4f0d28"
-dependencies = [
- "aws-smithy-types",
- "bytes",
- "bytes-utils",
- "futures-core",
- "http",
- "http-body",
- "hyper",
- "once_cell",
- "percent-encoding",
- "pin-project-lite",
- "pin-utils",
- "tokio",
- "tokio-util",
- "tracing",
-]
-
-[[package]]
-name = "aws-smithy-http-tower"
-version = "0.55.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3ae4f6c5798a247fac98a867698197d9ac22643596dc3777f0c76b91917616b9"
-dependencies = [
- "aws-smithy-http",
- "aws-smithy-types",
- "bytes",
- "http",
- "http-body",
- "pin-project-lite",
- "tower",
- "tracing",
-]
-
-[[package]]
-name = "aws-smithy-json"
-version = "0.55.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "23f9f42fbfa96d095194a632fbac19f60077748eba536eb0b9fecc28659807f8"
-dependencies = [
- "aws-smithy-types",
-]
-
-[[package]]
-name = "aws-smithy-query"
-version = "0.55.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "98819eb0b04020a1c791903533b638534ae6c12e2aceda3e6e6fba015608d51d"
-dependencies = [
- "aws-smithy-types",
- "urlencoding",
-]
-
-[[package]]
-name = "aws-smithy-types"
-version = "0.55.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "16a3d0bf4f324f4ef9793b86a1701d9700fbcdbd12a846da45eed104c634c6e8"
-dependencies = [
- "base64-simd",
- "itoa",
- "num-integer",
- "ryu",
- "time",
-]
-
-[[package]]
-name = "aws-smithy-xml"
-version = "0.55.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b1b9d12875731bd07e767be7baad95700c3137b56730ec9ddeedb52a5e5ca63b"
-dependencies = [
- "xmlparser",
-]
-
-[[package]]
-name = "aws-types"
-version = "0.55.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6dd209616cc8d7bfb82f87811a5c655dc97537f592689b18743bddf5dc5c4829"
-dependencies = [
- "aws-credential-types",
- "aws-smithy-async",
- "aws-smithy-client",
- "aws-smithy-http",
- "aws-smithy-types",
- "http",
- "rustc_version",
- "tracing",
-]
-
[[package]]
name = "axum"
version = "0.6.20"
@@ -519,16 +175,6 @@
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "414dcefbc63d77c526a76b3afcf6fbb9b5e2791c19c3aa2297733208750c6e53"
-[[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 = "base64ct"
version = "1.6.0"
@@ -583,16 +229,6 @@
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be"
-[[package]]
-name = "bytes-utils"
-version = "0.1.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e47d3a8076e283f3acd27400535992edb3ba4b5bb72f8891ad8fbe7932a7d4b9"
-dependencies = [
- "bytes",
- "either",
-]
-
[[package]]
name = "bytesize"
version = "1.3.0"
@@ -633,10 +269,6 @@
version = "0.1.0"
dependencies = [
"anyhow",
- "aws-config",
- "aws-sdk-dynamodb",
- "aws-sdk-secretsmanager",
- "aws-types",
"base64 0.21.3",
"chrono",
"constant_time_eq",
@@ -777,12 +409,6 @@
"const-oid",
]
-[[package]]
-name = "deranged"
-version = "0.3.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f2696e8a945f658fd14dc3b87242e6b80cd0f36ff04ea560fa39082368847946"
-
[[package]]
name = "derive-where"
version = "1.0.0-rc.3"
@@ -899,15 +525,6 @@
"libc",
]
-[[package]]
-name = "fastrand"
-version = "1.9.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be"
-dependencies = [
- "instant",
-]
-
[[package]]
name = "fastrand"
version = "2.0.0"
@@ -1197,21 +814,6 @@
"want",
]
-[[package]]
-name = "hyper-rustls"
-version = "0.23.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1788965e61b367cd03a62950836d5cd41560c3577d90e40e0819373194d1661c"
-dependencies = [
- "http",
- "hyper",
- "log",
- "rustls 0.20.9",
- "rustls-native-certs",
- "tokio",
- "tokio-rustls 0.23.4",
-]
-
[[package]]
name = "hyper-timeout"
version = "0.4.1"
@@ -1290,15 +892,6 @@
"hashbrown 0.14.0",
]
-[[package]]
-name = "instant"
-version = "0.1.12"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c"
-dependencies = [
- "cfg-if",
-]
-
[[package]]
name = "ipnet"
version = "2.8.0"
@@ -1444,16 +1037,6 @@
"winapi",
]
-[[package]]
-name = "num-integer"
-version = "0.1.45"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9"
-dependencies = [
- "autocfg",
- "num-traits",
-]
-
[[package]]
name = "num-traits"
version = "0.2.16"
@@ -1554,12 +1137,6 @@
"vcpkg",
]
-[[package]]
-name = "outref"
-version = "0.5.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4030760ffd992bef45b0ae3f10ce1aba99e33464c90d14dd7c039884963ddc7a"
-
[[package]]
name = "overload"
version = "0.1.1"
@@ -1885,18 +1462,6 @@
"windows-sys",
]
-[[package]]
-name = "rustls"
-version = "0.20.9"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1b80e3dec595989ea8510028f30c408a4630db12c9cbb8de34203b89d6577e99"
-dependencies = [
- "log",
- "ring",
- "sct",
- "webpki",
-]
-
[[package]]
name = "rustls"
version = "0.21.7"
@@ -1909,18 +1474,6 @@
"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.3"
@@ -2179,7 +1732,7 @@
checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef"
dependencies = [
"cfg-if",
- "fastrand 2.0.0",
+ "fastrand",
"redox_syscall",
"rustix",
"windows-sys",
@@ -2215,33 +1768,6 @@
"once_cell",
]
-[[package]]
-name = "time"
-version = "0.3.28"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "17f6bb557fd245c28e6411aa56b6403c689ad95061f50e4be16c274e70a17e48"
-dependencies = [
- "deranged",
- "serde",
- "time-core",
- "time-macros",
-]
-
-[[package]]
-name = "time-core"
-version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb"
-
-[[package]]
-name = "time-macros"
-version = "0.2.14"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1a942f44339478ef67935ab2bbaec2fb0322496cf3cbe84b261e06ac3814c572"
-dependencies = [
- "time-core",
-]
-
[[package]]
name = "tinyvec"
version = "1.6.0"
@@ -2305,24 +1831,13 @@
"tokio",
]
-[[package]]
-name = "tokio-rustls"
-version = "0.23.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59"
-dependencies = [
- "rustls 0.20.9",
- "tokio",
- "webpki",
-]
-
[[package]]
name = "tokio-rustls"
version = "0.24.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081"
dependencies = [
- "rustls 0.21.7",
+ "rustls",
"tokio",
]
@@ -2418,7 +1933,7 @@
"prost",
"rustls-pemfile",
"tokio",
- "tokio-rustls 0.24.1",
+ "tokio-rustls",
"tokio-stream",
"tower",
"tower-layer",
@@ -2492,7 +2007,6 @@
checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8"
dependencies = [
"cfg-if",
- "log",
"pin-project-lite",
"tracing-attributes",
"tracing-core",
@@ -2644,12 +2158,6 @@
"percent-encoding",
]
-[[package]]
-name = "urlencoding"
-version = "2.1.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da"
-
[[package]]
name = "utf-8"
version = "0.7.6"
@@ -2702,12 +2210,6 @@
"zeroize",
]
-[[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"
@@ -2812,16 +2314,6 @@
"wasm-bindgen",
]
-[[package]]
-name = "webpki"
-version = "0.22.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f0e74f82d49d545ad128049b7e88f6576df2da6b02e9ce565c6f533be576957e"
-dependencies = [
- "ring",
- "untrusted",
-]
-
[[package]]
name = "webpki-roots"
version = "0.23.1"
@@ -2949,12 +2441,6 @@
"windows-sys",
]
-[[package]]
-name = "xmlparser"
-version = "0.13.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4d25c75bf9ea12c4040a97f829154768bbbce366287e2dc044af160cd79a13fd"
-
[[package]]
name = "zeroize"
version = "1.6.0"
diff --git a/services/feature-flags/Cargo.toml b/services/feature-flags/Cargo.toml
--- a/services/feature-flags/Cargo.toml
+++ b/services/feature-flags/Cargo.toml
@@ -13,7 +13,7 @@
aws-types = "0.55"
aws-sdk-dynamodb = "0.27"
clap = { version = "4.0", features = ["derive", "env"] }
-comm-lib = { path = "../../shared/comm-lib" }
+comm-lib = { path = "../../shared/comm-lib", features = ["aws"] }
http = "0.2"
once_cell = "1.17"
serde = { version = "1.0", features = ["derive"] }
diff --git a/services/reports/Cargo.toml b/services/reports/Cargo.toml
--- a/services/reports/Cargo.toml
+++ b/services/reports/Cargo.toml
@@ -17,6 +17,7 @@
"blob-client",
"http",
"crypto",
+ "aws",
] }
derive_more = "0.99"
hex = "0.4"
diff --git a/shared/comm-lib/Cargo.toml b/shared/comm-lib/Cargo.toml
--- a/shared/comm-lib/Cargo.toml
+++ b/shared/comm-lib/Cargo.toml
@@ -22,14 +22,16 @@
"dep:actix-web-httpauth",
]
crypto = ["dep:aead", "dep:aes-gcm", "dep:bytes"]
+aws = [
+ "dep:aws-config",
+ "dep:aws-sdk-dynamodb",
+ "dep:aws-sdk-secretsmanager",
+ "dep:aws-types",
+]
[dependencies]
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
-aws-config = "0.55"
-aws-sdk-dynamodb = "0.27"
-aws-sdk-secretsmanager = "0.27"
-aws-types = "0.55"
base64 = "0.21"
chrono = "0.4.31"
constant_time_eq = "0.3"
@@ -39,6 +41,11 @@
tokio = "1.32"
tracing = "0.1"
anyhow = "1.0.74"
+# aws dependencies
+aws-config = { version = "0.55", optional = true }
+aws-sdk-dynamodb = { version = "0.27", optional = true }
+aws-sdk-secretsmanager = { version = "0.27", optional = true }
+aws-types = { version = "0.55", optional = true }
# blob client dependencies
bytes = { version = "1.4", optional = true }
futures-core = { version = "0.3", optional = true }
diff --git a/shared/comm-lib/src/auth/mod.rs b/shared/comm-lib/src/auth/mod.rs
--- a/shared/comm-lib/src/auth/mod.rs
+++ b/shared/comm-lib/src/auth/mod.rs
@@ -1,5 +1,7 @@
+#[cfg(feature = "aws")]
mod service;
mod types;
+#[cfg(feature = "aws")]
pub use service::*;
pub use types::*;
diff --git a/shared/comm-lib/src/blob/types.rs b/shared/comm-lib/src/blob/types.rs
--- a/shared/comm-lib/src/blob/types.rs
+++ b/shared/comm-lib/src/blob/types.rs
@@ -1,11 +1,4 @@
-use aws_sdk_dynamodb::types::AttributeValue;
use derive_more::Constructor;
-use std::collections::HashMap;
-
-use crate::database::{AttributeTryInto, DBItemError, TryFromAttribute};
-
-const BLOB_HASH_DDB_MAP_KEY: &str = "blob_hash";
-const HOLDER_DDB_MAP_KEY: &str = "holder";
/// Blob owning information - stores both blob_hash and holder
#[derive(Clone, Debug, Constructor)]
@@ -14,41 +7,52 @@
pub holder: String,
}
-impl From<BlobInfo> for AttributeValue {
- fn from(value: BlobInfo) -> Self {
- let map = HashMap::from([
- (
- BLOB_HASH_DDB_MAP_KEY.to_string(),
- AttributeValue::S(value.blob_hash),
- ),
- (
- HOLDER_DDB_MAP_KEY.to_string(),
- AttributeValue::S(value.holder),
- ),
- ]);
- AttributeValue::M(map)
+#[cfg(feature = "aws")]
+mod db_conversions {
+ use super::*;
+ use crate::database::{AttributeTryInto, DBItemError, TryFromAttribute};
+ use aws_sdk_dynamodb::types::AttributeValue;
+ use std::collections::HashMap;
+
+ const BLOB_HASH_DDB_MAP_KEY: &str = "blob_hash";
+ const HOLDER_DDB_MAP_KEY: &str = "holder";
+
+ impl From<BlobInfo> for AttributeValue {
+ fn from(value: BlobInfo) -> Self {
+ let map = HashMap::from([
+ (
+ BLOB_HASH_DDB_MAP_KEY.to_string(),
+ AttributeValue::S(value.blob_hash),
+ ),
+ (
+ HOLDER_DDB_MAP_KEY.to_string(),
+ AttributeValue::S(value.holder),
+ ),
+ ]);
+ AttributeValue::M(map)
+ }
}
-}
-impl From<&BlobInfo> for AttributeValue {
- fn from(value: &BlobInfo) -> Self {
- AttributeValue::from(value.to_owned())
+ impl From<&BlobInfo> for AttributeValue {
+ fn from(value: &BlobInfo) -> Self {
+ AttributeValue::from(value.to_owned())
+ }
}
-}
-impl TryFromAttribute for BlobInfo {
- fn try_from_attr(
- attribute_name: impl Into<String>,
- attribute: Option<AttributeValue>,
- ) -> Result<Self, DBItemError> {
- let attr_name: String = attribute_name.into();
- let mut inner_map: HashMap<String, AttributeValue> =
- attribute.attr_try_into(&attr_name)?;
- let blob_hash = inner_map
- .remove("blob_hash")
- .attr_try_into(format!("{attr_name}.blob_hash"))?;
- let holder = inner_map
- .remove("holder")
- .attr_try_into(format!("{attr_name}.holder"))?;
- Ok(BlobInfo { blob_hash, holder })
+ impl TryFromAttribute for BlobInfo {
+ fn try_from_attr(
+ attribute_name: impl Into<String>,
+ attribute: Option<AttributeValue>,
+ ) -> Result<Self, DBItemError> {
+ let attr_name: String = attribute_name.into();
+ let mut inner_map: HashMap<String, AttributeValue> =
+ attribute.attr_try_into(&attr_name)?;
+ let blob_hash = inner_map
+ .remove("blob_hash")
+ .attr_try_into(format!("{attr_name}.blob_hash"))?;
+ let holder = inner_map
+ .remove("holder")
+ .attr_try_into(format!("{attr_name}.holder"))?;
+ Ok(BlobInfo { blob_hash, holder })
+ }
}
}
diff --git a/shared/comm-lib/src/lib.rs b/shared/comm-lib/src/lib.rs
--- a/shared/comm-lib/src/lib.rs
+++ b/shared/comm-lib/src/lib.rs
@@ -4,6 +4,7 @@
pub mod constants;
#[cfg(feature = "crypto")]
pub mod crypto;
+#[cfg(feature = "aws")]
pub mod database;
#[cfg(feature = "http")]
pub mod http;

File Metadata

Mime Type
text/plain
Expires
Sat, Jan 3, 2:13 PM (17 h, 27 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5889171
Default Alt Text
D10258.1767449582.diff (20 KB)

Event Timeline