From 963bff9507088f40a6e0799d153a702c6f6e3cfb Mon Sep 17 00:00:00 2001 From: John Lewis Date: Mon, 25 Nov 2024 13:46:45 +0100 Subject: [PATCH] feat(prime-domain): added canonical impl --- Cargo.lock | 610 +-------------------------- Cargo.toml | 1 - crates/models/src/artifact.rs | 18 + crates/models/src/photo.rs | 15 + crates/prime-domain/Cargo.toml | 2 +- crates/prime-domain/src/canonical.rs | 65 +++ crates/prime-domain/src/lib.rs | 11 +- crates/repos/src/lib.rs | 2 +- 8 files changed, 114 insertions(+), 610 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index aa26687..b6bb5b5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -41,21 +41,6 @@ dependencies = [ "alloc-no-stdlib", ] -[[package]] -name = "android-tzdata" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" - -[[package]] -name = "android_system_properties" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" -dependencies = [ - "libc", -] - [[package]] name = "any_spawner" version = "0.1.1" @@ -145,12 +130,6 @@ dependencies = [ "syn 2.0.89", ] -[[package]] -name = "atomic-waker" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" - [[package]] name = "attribute-derive" version = "0.9.2" @@ -339,15 +318,6 @@ 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 = "brotli" version = "7.0.0" @@ -387,17 +357,6 @@ version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da" -[[package]] -name = "bytes-stream" -version = "0.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c74d2aa520b426169bea4852a5926d5284bb5c02b4ba6940db269f951cf1f3a" -dependencies = [ - "bytes", - "futures-core", - "pin-project-lite", -] - [[package]] name = "camino" version = "1.1.9" @@ -421,25 +380,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "cfg_aliases" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" - -[[package]] -name = "chrono" -version = "0.4.38" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" -dependencies = [ - "android-tzdata", - "iana-time-zone", - "num-traits", - "serde", - "windows-targets", -] - [[package]] name = "codee" version = "0.2.0" @@ -534,22 +474,6 @@ dependencies = [ "unicode-segmentation", ] -[[package]] -name = "core-foundation" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b55271e5c8c478ad3f38ad24ef34923091e0548492a266d19b3c0b4d82574c63" -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 = "crc32fast" version = "1.4.2" @@ -575,16 +499,6 @@ dependencies = [ "stream-tools", ] -[[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 = "dashmap" version = "6.1.0" @@ -642,16 +556,6 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "339544cc9e2c4dc3fc7149fd630c5f22263a4fdf18a98afd0075784968b5cf00" -[[package]] -name = "digest" -version = "0.10.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" -dependencies = [ - "block-buffer", - "crypto-common", -] - [[package]] name = "displaydoc" version = "0.2.5" @@ -663,12 +567,6 @@ dependencies = [ "syn 2.0.89", ] -[[package]] -name = "doc-comment" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" - [[package]] name = "drain_filter_polyfill" version = "0.1.3" @@ -862,16 +760,6 @@ dependencies = [ "slab", ] -[[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.1.16" @@ -961,25 +849,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "h2" -version = "0.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccae279728d634d083c00f6099cb58f01cc99c145b84b8be2f6c74618d79922e" -dependencies = [ - "atomic-waker", - "bytes", - "fnv", - "futures-core", - "futures-sink", - "http 1.1.0", - "indexmap 2.6.0", - "slab", - "tokio", - "tokio-util", - "tracing", -] - [[package]] name = "hashbrown" version = "0.12.3" @@ -1018,12 +887,6 @@ dependencies = [ "serde", ] -[[package]] -name = "heck" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" - [[package]] name = "hermit-abi" version = "0.3.9" @@ -1123,12 +986,6 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" -[[package]] -name = "humantime" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" - [[package]] name = "hydration_context" version = "0.2.0-rc1" @@ -1155,7 +1012,7 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", - "h2 0.3.26", + "h2", "http 0.2.12", "http-body 0.4.6", "httparse", @@ -1178,7 +1035,6 @@ dependencies = [ "bytes", "futures-channel", "futures-util", - "h2 0.4.7", "http 1.1.0", "http-body 1.0.1", "httparse", @@ -1187,25 +1043,6 @@ dependencies = [ "pin-project-lite", "smallvec", "tokio", - "want", -] - -[[package]] -name = "hyper-rustls" -version = "0.27.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333" -dependencies = [ - "futures-util", - "http 1.1.0", - "hyper 1.5.1", - "hyper-util", - "rustls 0.23.18", - "rustls-native-certs", - "rustls-pki-types", - "tokio", - "tokio-rustls 0.26.0", - "tower-service", ] [[package]] @@ -1227,39 +1064,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df2dcfbe0677734ab2f3ffa7fa7bfd4706bfdc1ef393f2ee30184aed67e631b4" dependencies = [ "bytes", - "futures-channel", "futures-util", "http 1.1.0", "http-body 1.0.1", "hyper 1.5.1", "pin-project-lite", - "socket2", "tokio", "tower-service", - "tracing", -] - -[[package]] -name = "iana-time-zone" -version = "0.1.61" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220" -dependencies = [ - "android_system_properties", - "core-foundation-sys", - "iana-time-zone-haiku", - "js-sys", - "wasm-bindgen", - "windows-core", -] - -[[package]] -name = "iana-time-zone-haiku" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" -dependencies = [ - "cc", ] [[package]] @@ -1433,12 +1244,6 @@ version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f958d3d68f4167080a18141e10381e7634563984a537f2a49a30fd8e53ac5767" -[[package]] -name = "ipnet" -version = "2.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddc24109865250148c2e0f3d25d4f0f479571723792d3802153c60922a4fb708" - [[package]] name = "iri-string" version = "0.7.7" @@ -1832,16 +1637,6 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" -[[package]] -name = "md-5" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" -dependencies = [ - "cfg-if", - "digest", -] - [[package]] name = "memchr" version = "2.7.4" @@ -1930,17 +1725,6 @@ dependencies = [ "serde", ] -[[package]] -name = "models" -version = "0.1.0" -source = "git+https://github.com/rambit-systems/rambit#3550e7852ee10030713225dde2d22b44c1dc5478" -dependencies = [ - "dvf", - "model", - "serde", - "ulid", -] - [[package]] name = "multer" version = "3.1.0" @@ -2025,36 +1809,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "object_store" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6da452820c715ce78221e8202ccc599b4a52f3e1eb3eedb487b680c81a8e3f3" -dependencies = [ - "async-trait", - "base64 0.22.1", - "bytes", - "chrono", - "futures", - "humantime", - "hyper 1.5.1", - "itertools 0.13.0", - "md-5", - "parking_lot", - "percent-encoding", - "quick-xml", - "rand 0.8.5", - "reqwest", - "ring", - "serde", - "serde_json", - "snafu", - "tokio", - "tracing", - "url", - "walkdir", -] - [[package]] name = "oco_ref" version = "0.2.0" @@ -2071,12 +1825,6 @@ 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 = "or_poisoned" version = "0.1.0" @@ -2201,8 +1949,8 @@ dependencies = [ "crunch", "hex", "miette", - "models 0.1.0", - "repos 0.1.0 (git+https://github.com/rambit-systems/rambit)", + "models", + "repos", "thiserror 2.0.3", "tracing", ] @@ -2333,68 +2081,6 @@ dependencies = [ "syn 2.0.89", ] -[[package]] -name = "quick-xml" -version = "0.36.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7649a7b4df05aed9ea7ec6f628c67c9953a43869b8bc50929569b2999d443fe" -dependencies = [ - "memchr", - "serde", -] - -[[package]] -name = "quinn" -version = "0.11.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62e96808277ec6f97351a2380e6c25114bc9e67037775464979f3037c92d05ef" -dependencies = [ - "bytes", - "pin-project-lite", - "quinn-proto", - "quinn-udp", - "rustc-hash", - "rustls 0.23.18", - "socket2", - "thiserror 2.0.3", - "tokio", - "tracing", -] - -[[package]] -name = "quinn-proto" -version = "0.11.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2fe5ef3495d7d2e377ff17b1a8ce2ee2ec2a18cde8b6ad6619d65d0701c135d" -dependencies = [ - "bytes", - "getrandom 0.2.15", - "rand 0.8.5", - "ring", - "rustc-hash", - "rustls 0.23.18", - "rustls-pki-types", - "slab", - "thiserror 2.0.3", - "tinyvec", - "tracing", - "web-time", -] - -[[package]] -name = "quinn-udp" -version = "0.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d5a626c6807713b15cac82a6acaccd6043c9a5408c24baae07611fec3f243da" -dependencies = [ - "cfg_aliases", - "libc", - "once_cell", - "socket2", - "tracing", - "windows-sys 0.59.0", -] - [[package]] name = "quote" version = "1.0.37" @@ -2608,70 +2294,10 @@ dependencies = [ "db", "hex", "miette", - "models 0.1.0", - "tracing", -] - -[[package]] -name = "repos" -version = "0.1.0" -source = "git+https://github.com/rambit-systems/rambit#3550e7852ee10030713225dde2d22b44c1dc5478" -dependencies = [ - "async-trait", - "db", - "hex", - "miette", - "models 0.1.0 (git+https://github.com/rambit-systems/rambit)", - "storage", - "tokio", + "models", "tracing", ] -[[package]] -name = "reqwest" -version = "0.12.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a77c62af46e79de0a562e1a9849205ffcb7fc1238876e9bd743357570e04046f" -dependencies = [ - "base64 0.22.1", - "bytes", - "futures-core", - "futures-util", - "h2 0.4.7", - "http 1.1.0", - "http-body 1.0.1", - "http-body-util", - "hyper 1.5.1", - "hyper-rustls", - "hyper-util", - "ipnet", - "js-sys", - "log", - "mime", - "once_cell", - "percent-encoding", - "pin-project-lite", - "quinn", - "rustls 0.23.18", - "rustls-native-certs", - "rustls-pemfile 2.2.0", - "rustls-pki-types", - "serde", - "serde_json", - "serde_urlencoded", - "sync_wrapper 1.0.2", - "tokio", - "tokio-rustls 0.26.0", - "tokio-util", - "tower-service", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "wasm-streams", - "web-sys", - "windows-registry", -] - [[package]] name = "ring" version = "0.17.8" @@ -2744,36 +2370,10 @@ checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" dependencies = [ "log", "ring", - "rustls-webpki 0.101.7", + "rustls-webpki", "sct", ] -[[package]] -name = "rustls" -version = "0.23.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c9cc1d47e243d655ace55ed38201c19ae02c148ae56412ab8750e8f0166ab7f" -dependencies = [ - "once_cell", - "ring", - "rustls-pki-types", - "rustls-webpki 0.102.8", - "subtle", - "zeroize", -] - -[[package]] -name = "rustls-native-certs" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcff2dd52b58a8d98a70243663a0d234c4e2b79235637849d15913394a247d3" -dependencies = [ - "openssl-probe", - "rustls-pki-types", - "schannel", - "security-framework", -] - [[package]] name = "rustls-pemfile" version = "1.0.4" @@ -2783,24 +2383,6 @@ dependencies = [ "base64 0.21.7", ] -[[package]] -name = "rustls-pemfile" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50" -dependencies = [ - "rustls-pki-types", -] - -[[package]] -name = "rustls-pki-types" -version = "1.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16f1201b3c9a7ee8039bcadc17b7e605e2945b27eee7631788c1bd2b0643674b" -dependencies = [ - "web-time", -] - [[package]] name = "rustls-webpki" version = "0.101.7" @@ -2811,17 +2393,6 @@ dependencies = [ "untrusted", ] -[[package]] -name = "rustls-webpki" -version = "0.102.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64ca1bc8749bd4cf37b5ce386cc146580777b4e8572c7b97baf22c83f444bee9" -dependencies = [ - "ring", - "rustls-pki-types", - "untrusted", -] - [[package]] name = "rustversion" version = "1.0.18" @@ -2843,15 +2414,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "schannel" -version = "0.1.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f29ebaa345f945cec9fbbc532eb307f0fdad8161f281b6369539c8d84876b3d" -dependencies = [ - "windows-sys 0.59.0", -] - [[package]] name = "scopeguard" version = "1.2.0" @@ -2868,29 +2430,6 @@ dependencies = [ "untrusted", ] -[[package]] -name = "security-framework" -version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1415a607e92bec364ea2cf9264646dcce0f91e6d65281bd6f2819cca3bf39c8" -dependencies = [ - "bitflags 2.6.0", - "core-foundation", - "core-foundation-sys", - "libc", - "security-framework-sys", -] - -[[package]] -name = "security-framework-sys" -version = "2.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa39c7303dc58b5543c94d22c1766b0d31f2ee58306363ea622b10bbc075eaa2" -dependencies = [ - "core-foundation-sys", - "libc", -] - [[package]] name = "semver" version = "1.0.23" @@ -3135,28 +2674,6 @@ version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" -[[package]] -name = "snafu" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4de37ad025c587a29e8f3f5605c00f70b98715ef90b9061a815b9e59e9042d6" -dependencies = [ - "doc-comment", - "snafu-derive", -] - -[[package]] -name = "snafu-derive" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "990079665f075b699031e9c08fd3ab99be5029b96f3b78dc0709e8f77e4efebf" -dependencies = [ - "heck", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "snap" version = "1.1.1" @@ -3190,26 +2707,6 @@ name = "starc" version = "0.1.0" source = "git+https://github.com/rambit-systems/rambit#3550e7852ee10030713225dde2d22b44c1dc5478" -[[package]] -name = "storage" -version = "0.1.0" -source = "git+https://github.com/rambit-systems/rambit#3550e7852ee10030713225dde2d22b44c1dc5478" -dependencies = [ - "async-trait", - "bytes-stream", - "dvf", - "futures", - "hex", - "miette", - "object_store", - "serde", - "stream-tools", - "thiserror 1.0.69", - "tokio", - "tokio-util", - "tracing", -] - [[package]] name = "stream-tools" version = "0.1.0" @@ -3219,12 +2716,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "subtle" -version = "2.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" - [[package]] name = "syn" version = "1.0.109" @@ -3270,9 +2761,6 @@ name = "sync_wrapper" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" -dependencies = [ - "futures-core", -] [[package]] name = "synstructure" @@ -3421,21 +2909,6 @@ dependencies = [ "zerovec", ] -[[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.1" @@ -3481,18 +2954,7 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls 0.21.12", - "tokio", -] - -[[package]] -name = "tokio-rustls" -version = "0.26.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" -dependencies = [ - "rustls 0.23.18", - "rustls-pki-types", + "rustls", "tokio", ] @@ -3515,7 +2977,6 @@ checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" dependencies = [ "bytes", "futures-core", - "futures-io", "futures-sink", "pin-project-lite", "tokio", @@ -3566,7 +3027,7 @@ dependencies = [ "axum 0.6.20", "base64 0.21.7", "bytes", - "h2 0.3.26", + "h2", "http 0.2.12", "http-body 0.4.6", "hyper 0.14.31", @@ -3574,10 +3035,10 @@ dependencies = [ "percent-encoding", "pin-project", "prost", - "rustls 0.21.12", - "rustls-pemfile 1.0.4", + "rustls", + "rustls-pemfile", "tokio", - "tokio-rustls 0.24.1", + "tokio-rustls", "tokio-stream", "tower 0.4.13", "tower-layer", @@ -3756,12 +3217,6 @@ dependencies = [ "syn 2.0.89", ] -[[package]] -name = "typenum" -version = "1.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" - [[package]] name = "ulid" version = "1.1.3" @@ -4028,45 +3483,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "windows-core" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" -dependencies = [ - "windows-targets", -] - -[[package]] -name = "windows-registry" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0" -dependencies = [ - "windows-result", - "windows-strings", - "windows-targets", -] - -[[package]] -name = "windows-result" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" -dependencies = [ - "windows-targets", -] - -[[package]] -name = "windows-strings" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" -dependencies = [ - "windows-result", - "windows-targets", -] - [[package]] name = "windows-sys" version = "0.52.0" @@ -4248,12 +3664,6 @@ dependencies = [ "synstructure", ] -[[package]] -name = "zeroize" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" - [[package]] name = "zerovec" version = "0.10.4" diff --git a/Cargo.toml b/Cargo.toml index 7c77830..3d79755 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,6 @@ db = { git = "https://github.com/rambit-systems/rambit" } dvf = { git = "https://github.com/rambit-systems/rambit" } hex = { git = "https://github.com/rambit-systems/rambit" } model = { git = "https://github.com/rambit-systems/rambit" } -repos = { git = "https://github.com/rambit-systems/rambit" } # async tokio = { version = "1", features = ["full"] } diff --git a/crates/models/src/artifact.rs b/crates/models/src/artifact.rs index 97fc2f8..f9b1ece 100644 --- a/crates/models/src/artifact.rs +++ b/crates/models/src/artifact.rs @@ -53,3 +53,21 @@ impl Model for Artifact { fn id(&self) -> ArtifactRecordId { self.id } } + +/// A request to create a new [`Artifact`]. +pub struct ArtifactCreateRequest { + /// The artifact's path. + pub path: ArtifactPath, + /// The artifact's compression status. + pub size: dvf::CompressionStatus, +} + +impl From for Artifact { + fn from(input: ArtifactCreateRequest) -> Self { + Self { + id: ArtifactRecordId::default(), + path: input.path, + size: input.size, + } + } +} diff --git a/crates/models/src/photo.rs b/crates/models/src/photo.rs index 4df370f..5d68010 100644 --- a/crates/models/src/photo.rs +++ b/crates/models/src/photo.rs @@ -36,3 +36,18 @@ impl Model for Photo { fn id(&self) -> PhotoRecordId { self.id } } + +/// A request to create a new [`Photo`]. +pub struct PhotoCreateRequest { + /// The photo's artifacts. + pub artifacts: PhotoArtifacts, +} + +impl From for Photo { + fn from(input: PhotoCreateRequest) -> Self { + Self { + id: PhotoRecordId::default(), + artifacts: input.artifacts, + } + } +} diff --git a/crates/prime-domain/Cargo.toml b/crates/prime-domain/Cargo.toml index 7a26c6d..8736938 100644 --- a/crates/prime-domain/Cargo.toml +++ b/crates/prime-domain/Cargo.toml @@ -5,10 +5,10 @@ edition = "2021" [dependencies] models = { path = "../models" } +repos = { path = "../repos" } crunch.workspace = true hex.workspace = true -repos.workspace = true tracing.workspace = true diff --git a/crates/prime-domain/src/canonical.rs b/crates/prime-domain/src/canonical.rs index e69de29..b5f3d07 100644 --- a/crates/prime-domain/src/canonical.rs +++ b/crates/prime-domain/src/canonical.rs @@ -0,0 +1,65 @@ +use hex::health; +use models::{Photo, PhotoCreateRequest, PhotoRecordId}; +use repos::FetchModelError; + +use crate::PrimeDomainService; + +/// The canonical implementation of [`PrimeDomainService`]. +pub struct PrimeDomainServiceCanonical< + PR: repos::ModelRepository< + Model = Photo, + ModelCreateRequest = PhotoCreateRequest, + CreateError = repos::CreateModelError, + >, +> { + photo_repo: PR, +} + +impl PrimeDomainServiceCanonical +where + PR: repos::ModelRepository< + Model = Photo, + ModelCreateRequest = PhotoCreateRequest, + CreateError = repos::CreateModelError, + >, +{ + /// Creates a new [`PrimeDomainServiceCanonical`] with the given photo + /// repository. + pub fn new(photo_repo: PR) -> Self { Self { photo_repo } } +} + +#[async_trait::async_trait] +impl PrimeDomainService for PrimeDomainServiceCanonical +where + PR: repos::ModelRepository< + Model = Photo, + ModelCreateRequest = PhotoCreateRequest, + CreateError = repos::CreateModelError, + >, +{ + async fn fetch_photo_by_id( + &self, + id: PhotoRecordId, + ) -> Result, FetchModelError> { + self.photo_repo.fetch_model_by_id(id).await + } +} + +#[async_trait::async_trait] +impl health::HealthReporter for PrimeDomainServiceCanonical +where + PR: repos::ModelRepository< + Model = Photo, + ModelCreateRequest = PhotoCreateRequest, + CreateError = repos::CreateModelError, + >, +{ + fn name(&self) -> &'static str { stringify!(PrimeDomainServiceCanonical) } + async fn health_check(&self) -> health::ComponentHealth { + health::AdditiveComponentHealth::from_futures(vec![self + .photo_repo + .health_report()]) + .await + .into() + } +} diff --git a/crates/prime-domain/src/lib.rs b/crates/prime-domain/src/lib.rs index 374b3e6..33f46d9 100644 --- a/crates/prime-domain/src/lib.rs +++ b/crates/prime-domain/src/lib.rs @@ -7,8 +7,10 @@ use std::sync::Arc; pub use hex; use hex::Hexagonal; -use models::{Artifact, ArtifactRecordId, Photo, PhotoRecordId}; -use repos::db::FetchModelError; +use models::{Photo, PhotoRecordId}; +use repos::FetchModelError; + +pub use self::canonical::*; /// A dynamic [`PrimeDomainService`] trait object. pub type DynPrimeDomainService = Arc>; @@ -16,11 +18,6 @@ pub type DynPrimeDomainService = Arc>; /// The prime domain service trait. #[async_trait::async_trait] pub trait PrimeDomainService: Hexagonal { - /// Fetch an [`Artifact`] by its ID. - async fn fetch_cache_by_id( - &self, - id: ArtifactRecordId, - ) -> Result, FetchModelError>; /// Fetch a [`Photo`] by its ID. async fn fetch_photo_by_id( &self, diff --git a/crates/repos/src/lib.rs b/crates/repos/src/lib.rs index 951e640..f0152fe 100644 --- a/crates/repos/src/lib.rs +++ b/crates/repos/src/lib.rs @@ -1,6 +1,6 @@ //! Repositories for use in services. -use db::{FetchModelByIndexError, FetchModelError}; +pub use db::{CreateModelError, FetchModelByIndexError, FetchModelError}; use hex::Hexagonal; use miette::Result; use models::EitherSlug;