diff --git a/backend/api/Cargo.lock b/backend/api/Cargo.lock index 7a8f69ff12..39c75499c7 100644 --- a/backend/api/Cargo.lock +++ b/backend/api/Cargo.lock @@ -101,7 +101,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "465a6172cf69b960917811022d8f29bc0b7fa1398bc4f78b3c466673db1213b6" dependencies = [ "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -217,7 +217,7 @@ dependencies = [ "actix-router", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -408,7 +408,7 @@ checksum = "76464446b8bc32758d7e88ee1a804d9914cd9b1cb264c029899680b0be29826f" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -476,6 +476,18 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + [[package]] name = "blake2" version = "0.9.2" @@ -947,7 +959,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.9.3", - "syn", + "syn 1.0.109", ] [[package]] @@ -961,7 +973,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.10.0", - "syn", + "syn 1.0.109", ] [[package]] @@ -972,7 +984,7 @@ checksum = "d9b5a2f4ac4969822c62224815d069952656cadc7084fdca9751e6d959189b72" dependencies = [ "darling_core 0.10.2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -983,7 +995,7 @@ checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835" dependencies = [ "darling_core 0.13.4", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1020,7 +1032,7 @@ checksum = "ee7e7ea0dba407429d816e8e38dda1a467cd74737722f2ccc8eae60429a1a3ab" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1033,7 +1045,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version", - "syn", + "syn 1.0.109", ] [[package]] @@ -1045,7 +1057,7 @@ dependencies = [ "darling 0.10.2", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1212,7 +1224,7 @@ checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", "synstructure", ] @@ -1271,6 +1283,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + [[package]] name = "futures" version = "0.3.24" @@ -1353,7 +1371,7 @@ checksum = "42cd15d1c7456c04dbdf7e88bcd69760d74f3a798d6444e16974b505b0e62f17" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1472,7 +1490,7 @@ checksum = "bd411a8d6fe6ed182c435b1e011c269a6c581efa9da9672b37863b2c1c0871dd" dependencies = [ "quote", "sha2 0.10.5", - "syn", + "syn 1.0.109", ] [[package]] @@ -1887,13 +1905,14 @@ dependencies = [ "sha2 0.9.9", "shared", "sqlx", + "strong_id", "time 0.3.16", "tokio", "tracing", "tracing-actix-web", "tracing-subscriber", "url", - "uuid 1.1.2", + "uuid 1.4.0", "yup-oauth2", ] @@ -2045,7 +2064,7 @@ dependencies = [ "itertools", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -2315,7 +2334,7 @@ checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -2491,7 +2510,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -2561,7 +2580,7 @@ checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -2619,9 +2638,9 @@ checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" [[package]] name = "proc-macro2" -version = "1.0.47" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725" +checksum = "78803b62cbf1f46fde80d7c0e803111524b9877184cfe7c3033659490ac7a7da" dependencies = [ "unicode-ident", ] @@ -2644,13 +2663,19 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.21" +version = "1.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" +checksum = "573015e8ab27661678357f27dc26460738fd2b6c86e46f386fde94cb5d913105" dependencies = [ "proc-macro2", ] +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + [[package]] name = "rand" version = "0.7.3" @@ -3228,7 +3253,7 @@ checksum = "94ed3a816fb1d101812f83e789f888322c34e291f894f19590dc310963e87a00" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -3282,7 +3307,7 @@ checksum = "1fe39d9fbb0ebf5eb2c7cb7e2a47e4f462fad1379f1166b8ae49ad9eae89a7ca" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -3317,7 +3342,7 @@ dependencies = [ "darling 0.13.4", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -3397,12 +3422,13 @@ dependencies = [ "serde_repr", "serde_with", "sqlx", + "strong_id", "strum", "strum_macros", "thiserror", "unicode-segmentation", "url", - "uuid 1.1.2", + "uuid 1.4.0", ] [[package]] @@ -3466,7 +3492,7 @@ checksum = "133659a15339456eeeb07572eb02a91c91e9815e9cbc89566944d2c8d3efdbf6" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -3496,7 +3522,7 @@ checksum = "1508efa03c362e23817f96cde18abed596a25219a8b2c66e8db33c03543d315b" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -3584,7 +3610,7 @@ dependencies = [ "thiserror", "tokio-stream", "url", - "uuid 1.1.2", + "uuid 1.4.0", "whoami", ] @@ -3606,7 +3632,7 @@ dependencies = [ "sha2 0.10.5", "sqlx-core", "sqlx-rt", - "syn", + "syn 1.0.109", "url", ] @@ -3632,6 +3658,28 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "strong_id" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38de1d0d9040ac57048ffebae7fa3c233a7d6d76ac7670b506517512b1d692f2" +dependencies = [ + "bitvec", + "strong_id_macros", + "thiserror", + "uuid 1.4.0", +] + +[[package]] +name = "strong_id_macros" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1d0e4a9423aab05fde96fb9d9efd18e3d6d070392ee675fb7b2ad10149027ce" +dependencies = [ + "quote", + "syn 2.0.25", +] + [[package]] name = "strsim" version = "0.9.3" @@ -3659,7 +3707,7 @@ dependencies = [ "heck 0.3.3", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -3679,6 +3727,17 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "2.0.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15e3fc8c0c74267e2df136e5e5fb656a464158aa57624053375eb9c8c6e25ae2" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "synstructure" version = "0.12.6" @@ -3687,10 +3746,16 @@ checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", "unicode-xid", ] +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + [[package]] name = "tempfile" version = "3.6.0" @@ -3741,7 +3806,7 @@ checksum = "e8f2591983642de85c921015f3f070c665a197ed69e417af436115e3a1407487" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -3847,7 +3912,7 @@ checksum = "9724f9a975fb987ef7a3cd9be0350edcbe130698af5b8f7a631e23d42d052484" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -3925,7 +3990,7 @@ dependencies = [ "pin-project", "tracing", "tracing-futures", - "uuid 1.1.2", + "uuid 1.4.0", ] [[package]] @@ -3936,7 +4001,7 @@ checksum = "11c75893af559bc8e10716548bdef5cb2b983f8e637db9d0e15126b61b484ee2" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -4112,9 +4177,9 @@ dependencies = [ [[package]] name = "uuid" -version = "1.1.2" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd6469f4314d5f1ffec476e05f17cc9a78bc7a27a6a857842170bdf8d6f98d2f" +checksum = "d023da39d1fde5a8a3fe1f3e01ca9632ada0a63e9797de55a879d6e2236277be" dependencies = [ "getrandom 0.2.7", "serde", @@ -4193,7 +4258,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn", + "syn 1.0.109", "wasm-bindgen-shared", ] @@ -4227,7 +4292,7 @@ checksum = "5be8e654bdd9b79216c2929ab90721aa82faf65c48cdf08bdc4e7f51357b80da" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -4489,6 +4554,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] + [[package]] name = "xml-rs" version = "0.8.4" diff --git a/backend/api/Cargo.toml b/backend/api/Cargo.toml index ba62b95db6..a8723e1b11 100644 --- a/backend/api/Cargo.toml +++ b/backend/api/Cargo.toml @@ -60,6 +60,7 @@ quote = "1.0.18" hashfn = "0.2.0" csv = "1.1.6" async-stripe = { version = "0.22.2", features = ["runtime-tokio-hyper-rustls"] } +strong_id = { version = "0.2.0" } # project deps ji_core = { path = "../ji_core", features = ["db"] } diff --git a/backend/api/src/db/category.rs b/backend/api/src/db/category.rs index 9ef1eff4ed..46f6e15b28 100644 --- a/backend/api/src/db/category.rs +++ b/backend/api/src/db/category.rs @@ -47,7 +47,7 @@ order by index } #[instrument(skip(db))] -pub async fn get_exact(db: &sqlx::PgPool, ids: &[Uuid]) -> sqlx::Result> { +pub async fn get_exact(db: &sqlx::PgPool, ids: &[CategoryId]) -> sqlx::Result> { sqlx::query!( //language=SQL r#" @@ -60,7 +60,7 @@ from category inner join unnest($1::uuid[]) with ordinality t(id, ord) USING (id) order by t.ord "#, - ids + &ids.iter().map(|id| id.0).collect::>(), ) .fetch(db) .map_ok(|it| Category { @@ -81,11 +81,15 @@ order by t.ord } #[instrument(skip(db))] -pub async fn get_subtree(db: &sqlx::PgPool, ids: &[Uuid]) -> sqlx::Result> { - sqlx::query_file_as!(RawCategory, "query/category/get_subtree.sql", ids) - .fetch_all(db) - .await - .map(build_tree) +pub async fn get_subtree(db: &sqlx::PgPool, ids: &[CategoryId]) -> sqlx::Result> { + sqlx::query_file_as!( + RawCategory, + "query/category/get_subtree.sql", + &ids.iter().map(|id| id.0).collect::>() + ) + .fetch_all(db) + .await + .map(build_tree) } #[instrument(skip_all)] @@ -110,11 +114,18 @@ order by index } #[instrument(skip_all)] -pub async fn get_ancestor_tree(db: &sqlx::PgPool, ids: &[Uuid]) -> sqlx::Result> { - sqlx::query_file_as!(RawCategory, "query/category/get_ancestor_tree.sql", ids) - .fetch_all(db) - .await - .map(build_tree) +pub async fn get_ancestor_tree( + db: &sqlx::PgPool, + ids: &[CategoryId], +) -> sqlx::Result> { + sqlx::query_file_as!( + RawCategory, + "query/category/get_ancestor_tree.sql", + &ids.iter().map(|id| id.0).collect::>() + ) + .fetch_all(db) + .await + .map(build_tree) } #[instrument(skip(db))] diff --git a/backend/pages/Cargo.lock b/backend/pages/Cargo.lock index caa26c6865..2c9538e415 100644 --- a/backend/pages/Cargo.lock +++ b/backend/pages/Cargo.lock @@ -493,10 +493,22 @@ version = "0.19.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55f93d0ef3363c364d5976646a38f04cf67cfe1d4c8d160cdea02cab2c116b33" dependencies = [ - "funty", - "radium", + "funty 1.1.0", + "radium 0.5.3", "tap", - "wyz", + "wyz 0.2.0", +] + +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty 2.0.0", + "radium 0.7.0", + "tap", + "wyz 0.5.1", ] [[package]] @@ -1081,6 +1093,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + [[package]] name = "futures" version = "0.3.28" @@ -1838,8 +1856,8 @@ version = "6.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e7413f999671bd4745a7b624bd370a569fb6bc574b23c83a3c5ed2e453f3d5e2" dependencies = [ - "bitvec", - "funty", + "bitvec 0.19.6", + "funty 1.1.0", "lexical-core", "memchr", "version_check", @@ -2114,6 +2132,12 @@ version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "941ba9d78d8e2f7ce474c015eea4d9c6d25b6a3327f9832ee29a4de27f91bbb8" +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + [[package]] name = "rand" version = "0.7.3" @@ -2674,12 +2698,13 @@ dependencies = [ "serde_repr", "serde_with", "sqlx", + "strong_id", "strum", "strum_macros", "thiserror", "unicode-segmentation", "url", - "uuid 1.3.3", + "uuid 1.4.0", ] [[package]] @@ -2817,7 +2842,7 @@ dependencies = [ "thiserror", "tokio-stream", "url", - "uuid 1.3.3", + "uuid 1.4.0", "whoami", ] @@ -2871,6 +2896,29 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "strong_id" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38de1d0d9040ac57048ffebae7fa3c233a7d6d76ac7670b506517512b1d692f2" +dependencies = [ + "bitvec 1.0.1", + "serde", + "strong_id_macros", + "thiserror", + "uuid 1.4.0", +] + +[[package]] +name = "strong_id_macros" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1d0e4a9423aab05fde96fb9d9efd18e3d6d070392ee675fb7b2ad10149027ce" +dependencies = [ + "quote", + "syn 2.0.18", +] + [[package]] name = "strsim" version = "0.10.0" @@ -3252,10 +3300,11 @@ dependencies = [ [[package]] name = "uuid" -version = "1.3.3" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "345444e32442451b267fc254ae85a209c64be56d2890e601a0c37ff0c3c5ecd2" +checksum = "d023da39d1fde5a8a3fe1f3e01ca9632ada0a63e9797de55a879d6e2236277be" dependencies = [ + "getrandom 0.2.9", "serde", ] @@ -3603,6 +3652,15 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214" +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] + [[package]] name = "yup-oauth2" version = "7.0.1" diff --git a/backend/util/Cargo.lock b/backend/util/Cargo.lock index b062a5d0cd..a3cbba0435 100644 --- a/backend/util/Cargo.lock +++ b/backend/util/Cargo.lock @@ -25,7 +25,7 @@ checksum = "76464446b8bc32758d7e88ee1a804d9914cd9b1cb264c029899680b0be29826f" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.103", ] [[package]] @@ -46,6 +46,18 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + [[package]] name = "block-buffer" version = "0.9.0" @@ -160,7 +172,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn", + "syn 1.0.103", ] [[package]] @@ -289,7 +301,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.9.3", - "syn", + "syn 1.0.103", ] [[package]] @@ -303,7 +315,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.10.0", - "syn", + "syn 1.0.103", ] [[package]] @@ -314,7 +326,7 @@ checksum = "d9b5a2f4ac4969822c62224815d069952656cadc7084fdca9751e6d959189b72" dependencies = [ "darling_core 0.10.2", "quote", - "syn", + "syn 1.0.103", ] [[package]] @@ -325,7 +337,7 @@ checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835" dependencies = [ "darling_core 0.13.4", "quote", - "syn", + "syn 1.0.103", ] [[package]] @@ -337,7 +349,7 @@ dependencies = [ "darling 0.10.2", "proc-macro2", "quote", - "syn", + "syn 1.0.103", ] [[package]] @@ -449,6 +461,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + [[package]] name = "futures" version = "0.3.24" @@ -505,7 +523,7 @@ checksum = "42cd15d1c7456c04dbdf7e88bcd69760d74f3a798d6444e16974b505b0e62f17" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.103", ] [[package]] @@ -855,7 +873,7 @@ dependencies = [ "itertools", "proc-macro2", "quote", - "syn", + "syn 1.0.103", ] [[package]] @@ -1012,7 +1030,7 @@ checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.103", ] [[package]] @@ -1116,7 +1134,7 @@ dependencies = [ "proc-macro-hack", "proc-macro2", "quote", - "syn", + "syn 1.0.103", ] [[package]] @@ -1155,7 +1173,7 @@ checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.103", ] [[package]] @@ -1191,7 +1209,7 @@ dependencies = [ "proc-macro-error-attr", "proc-macro2", "quote", - "syn", + "syn 1.0.103", "version_check", ] @@ -1214,22 +1232,28 @@ checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" [[package]] name = "proc-macro2" -version = "1.0.47" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725" +checksum = "78803b62cbf1f46fde80d7c0e803111524b9877184cfe7c3033659490ac7a7da" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.21" +version = "1.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" +checksum = "573015e8ab27661678357f27dc26460738fd2b6c86e46f386fde94cb5d913105" dependencies = [ "proc-macro2", ] +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + [[package]] name = "rand" version = "0.7.3" @@ -1571,7 +1595,7 @@ checksum = "94ed3a816fb1d101812f83e789f888322c34e291f894f19590dc310963e87a00" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.103", ] [[package]] @@ -1593,7 +1617,7 @@ checksum = "1fe39d9fbb0ebf5eb2c7cb7e2a47e4f462fad1379f1166b8ae49ad9eae89a7ca" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.103", ] [[package]] @@ -1628,7 +1652,7 @@ dependencies = [ "darling 0.13.4", "proc-macro2", "quote", - "syn", + "syn 1.0.103", ] [[package]] @@ -1663,6 +1687,7 @@ dependencies = [ "serde_json", "serde_repr", "serde_with", + "strong_id", "strum", "strum_macros", "thiserror", @@ -1731,6 +1756,29 @@ dependencies = [ "lock_api", ] +[[package]] +name = "strong_id" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38de1d0d9040ac57048ffebae7fa3c233a7d6d76ac7670b506517512b1d692f2" +dependencies = [ + "bitvec", + "serde", + "strong_id_macros", + "thiserror", + "uuid", +] + +[[package]] +name = "strong_id_macros" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1d0e4a9423aab05fde96fb9d9efd18e3d6d070392ee675fb7b2ad10149027ce" +dependencies = [ + "quote", + "syn 2.0.25", +] + [[package]] name = "strsim" version = "0.9.3" @@ -1758,7 +1806,7 @@ dependencies = [ "heck 0.3.3", "proc-macro2", "quote", - "syn", + "syn 1.0.103", ] [[package]] @@ -1778,6 +1826,23 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "2.0.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15e3fc8c0c74267e2df136e5e5fb656a464158aa57624053375eb9c8c6e25ae2" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + [[package]] name = "tempfile" version = "3.3.0" @@ -1834,7 +1899,7 @@ checksum = "e8f2591983642de85c921015f3f070c665a197ed69e417af436115e3a1407487" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.103", ] [[package]] @@ -1891,7 +1956,7 @@ checksum = "9724f9a975fb987ef7a3cd9be0350edcbe130698af5b8f7a631e23d42d052484" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.103", ] [[package]] @@ -2012,10 +2077,11 @@ dependencies = [ [[package]] name = "uuid" -version = "1.1.2" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd6469f4314d5f1ffec476e05f17cc9a78bc7a27a6a857842170bdf8d6f98d2f" +checksum = "d023da39d1fde5a8a3fe1f3e01ca9632ada0a63e9797de55a879d6e2236277be" dependencies = [ + "getrandom 0.2.7", "serde", ] @@ -2080,7 +2146,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn", + "syn 1.0.103", "wasm-bindgen-shared", ] @@ -2114,7 +2180,7 @@ checksum = "5be8e654bdd9b79216c2929ab90721aa82faf65c48cdf08bdc4e7f51357b80da" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.103", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2218,6 +2284,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] + [[package]] name = "xml-rs" version = "0.8.4" diff --git a/frontend/apps/Cargo.lock b/frontend/apps/Cargo.lock index cc05a297cf..97e0c5cd83 100644 --- a/frontend/apps/Cargo.lock +++ b/frontend/apps/Cargo.lock @@ -1193,7 +1193,7 @@ checksum = "1e805d94e6b5001b651426cf4cd446b1ab5f319d27bab5c644f61de0a804360c" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.103", ] [[package]] @@ -1262,6 +1262,18 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + [[package]] name = "bstr" version = "0.2.17" @@ -1391,6 +1403,7 @@ dependencies = [ "serde_qs", "serde_repr", "shared", + "strong_id", "strum", "strum_macros", "thiserror", @@ -1500,7 +1513,7 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn", + "syn 1.0.103", ] [[package]] @@ -1517,7 +1530,7 @@ checksum = "309e4fb93eed90e1e14bea0da16b209f81813ba9fc7830c20ed151dd7bc0a4d7" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.103", ] [[package]] @@ -1561,7 +1574,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.9.3", - "syn", + "syn 1.0.103", ] [[package]] @@ -1575,7 +1588,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.10.0", - "syn", + "syn 1.0.103", ] [[package]] @@ -1589,7 +1602,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.10.0", - "syn", + "syn 1.0.103", ] [[package]] @@ -1600,7 +1613,7 @@ checksum = "d9b5a2f4ac4969822c62224815d069952656cadc7084fdca9751e6d959189b72" dependencies = [ "darling_core 0.10.2", "quote", - "syn", + "syn 1.0.103", ] [[package]] @@ -1611,7 +1624,7 @@ checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835" dependencies = [ "darling_core 0.13.4", "quote", - "syn", + "syn 1.0.103", ] [[package]] @@ -1622,7 +1635,7 @@ checksum = "7618812407e9402654622dd402b0a89dff9ba93badd6540781526117b92aab7e" dependencies = [ "darling_core 0.14.2", "quote", - "syn", + "syn 1.0.103", ] [[package]] @@ -1643,7 +1656,7 @@ dependencies = [ "darling 0.14.2", "proc-macro2", "quote", - "syn", + "syn 1.0.103", ] [[package]] @@ -1653,7 +1666,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f0314b72bed045f3a68671b3c86328386762c93f82d98c65c3cb5e5f573dd68" dependencies = [ "derive_builder_core", - "syn", + "syn 1.0.103", ] [[package]] @@ -1665,7 +1678,7 @@ dependencies = [ "darling 0.10.2", "proc-macro2", "quote", - "syn", + "syn 1.0.103", ] [[package]] @@ -1743,6 +1756,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + [[package]] name = "futures" version = "0.3.25" @@ -1799,7 +1818,7 @@ checksum = "bdfb8ce053d86b91919aad980c220b1fb8401a9394410e1c289ed7e66b61835d" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.103", ] [[package]] @@ -2153,7 +2172,7 @@ dependencies = [ "itertools", "proc-macro2", "quote", - "syn", + "syn 1.0.103", ] [[package]] @@ -2176,7 +2195,7 @@ checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.103", ] [[package]] @@ -2275,7 +2294,7 @@ checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.103", ] [[package]] @@ -2298,9 +2317,9 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.49" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57a8eca9f9c4ffde41714334dee777596264c7825420f521abc92b5b5deb63a5" +checksum = "78803b62cbf1f46fde80d7c0e803111524b9877184cfe7c3033659490ac7a7da" dependencies = [ "unicode-ident", ] @@ -2313,13 +2332,19 @@ checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3" [[package]] name = "quote" -version = "1.0.21" +version = "1.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" +checksum = "573015e8ab27661678357f27dc26460738fd2b6c86e46f386fde94cb5d913105" dependencies = [ "proc-macro2", ] +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + [[package]] name = "rand" version = "0.8.5" @@ -2470,7 +2495,7 @@ checksum = "4f1d362ca8fc9c3e3a7484440752472d68a6caa98f1ab81d99b5dfe517cec852" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.103", ] [[package]] @@ -2503,7 +2528,7 @@ checksum = "1fe39d9fbb0ebf5eb2c7cb7e2a47e4f462fad1379f1166b8ae49ad9eae89a7ca" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.103", ] [[package]] @@ -2526,7 +2551,7 @@ dependencies = [ "darling 0.13.4", "proc-macro2", "quote", - "syn", + "syn 1.0.103", ] [[package]] @@ -2549,6 +2574,7 @@ dependencies = [ "serde_json", "serde_repr", "serde_with", + "strong_id", "strum", "strum_macros", "thiserror", @@ -2573,6 +2599,28 @@ dependencies = [ "autocfg", ] +[[package]] +name = "strong_id" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38de1d0d9040ac57048ffebae7fa3c233a7d6d76ac7670b506517512b1d692f2" +dependencies = [ + "bitvec", + "strong_id_macros", + "thiserror", + "uuid", +] + +[[package]] +name = "strong_id_macros" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1d0e4a9423aab05fde96fb9d9efd18e3d6d070392ee675fb7b2ad10149027ce" +dependencies = [ + "quote", + "syn 2.0.25", +] + [[package]] name = "strsim" version = "0.9.3" @@ -2600,7 +2648,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn", + "syn 1.0.103", ] [[package]] @@ -2614,6 +2662,23 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "2.0.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15e3fc8c0c74267e2df136e5e5fb656a464158aa57624053375eb9c8c6e25ae2" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + [[package]] name = "termcolor" version = "1.1.3" @@ -2640,7 +2705,7 @@ checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.103", ] [[package]] @@ -2775,6 +2840,7 @@ dependencies = [ "serde_qs", "serde_repr", "shared", + "strong_id", "strum", "strum_macros", "thiserror", @@ -2789,9 +2855,9 @@ dependencies = [ [[package]] name = "uuid" -version = "1.2.1" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "feb41e78f93363bb2df8b0e86a2ca30eed7806ea16ea0c790d757cf93f79be83" +checksum = "d023da39d1fde5a8a3fe1f3e01ca9632ada0a63e9797de55a879d6e2236277be" dependencies = [ "getrandom", "serde", @@ -2839,7 +2905,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn", + "syn 1.0.103", "wasm-bindgen-shared", ] @@ -2873,7 +2939,7 @@ checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.103", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2948,6 +3014,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] + [[package]] name = "zxcvbn" version = "2.2.1" diff --git a/frontend/apps/Cargo.toml b/frontend/apps/Cargo.toml index 06ca36e486..4b1bfeaa50 100644 --- a/frontend/apps/Cargo.toml +++ b/frontend/apps/Cargo.toml @@ -98,6 +98,7 @@ zxcvbn = "2.1.2" const_format = "0.2.5" num-traits = "0.2" num-derive = "0.3" +strong_id = { version = "0.2.0" } web-sys = { version = "0.3.55", features = [ 'Url', 'Request', diff --git a/frontend/apps/crates/components/Cargo.toml b/frontend/apps/crates/components/Cargo.toml index 33d7cb5c8e..036bfd240d 100644 --- a/frontend/apps/crates/components/Cargo.toml +++ b/frontend/apps/crates/components/Cargo.toml @@ -45,6 +45,7 @@ rgb = { workspace = true } regex = { workspace = true } num-traits = { workspace = true } num-derive = { workspace = true } +strong_id = { workspace = true } [features] quiet = ["utils/quiet"] diff --git a/frontend/apps/crates/components/src/asset_search_bar/state/search_state.rs b/frontend/apps/crates/components/src/asset_search_bar/state/search_state.rs index c2bfa39739..5dc02068aa 100644 --- a/frontend/apps/crates/components/src/asset_search_bar/state/search_state.rs +++ b/frontend/apps/crates/components/src/asset_search_bar/state/search_state.rs @@ -51,7 +51,6 @@ impl SearchSelected { } pub fn from_query_params(search: SearchQueryParams) -> Self { - log::info!("{:?}", search.is_rated); let s = Self { affiliations: Mutable::new(HashSet::from_iter(search.affiliations)), categories: Mutable::new(HashSet::from_iter(search.categories)), @@ -61,7 +60,6 @@ impl SearchSelected { rated_only: Mutable::new(search.is_rated.unwrap_or(true)), query: Mutable::new(search.q), }; - log::info!("{:?}", s.rated_only); s } diff --git a/frontend/apps/crates/components/src/module/_common/edit/entry/state.rs b/frontend/apps/crates/components/src/module/_common/edit/entry/state.rs index 456db9160b..d824794007 100644 --- a/frontend/apps/crates/components/src/module/_common/edit/entry/state.rs +++ b/frontend/apps/crates/components/src/module/_common/edit/entry/state.rs @@ -30,6 +30,7 @@ use shared::{ }, }, }; +use strong_id::StrongUuid; use utils::{languages::Language, prelude::*}; use crate::audio::mixer::AUDIO_MIXER; diff --git a/frontend/apps/crates/components/src/module/_common/play/entry/state.rs b/frontend/apps/crates/components/src/module/_common/play/entry/state.rs index 4c6b3399eb..dccf4bb683 100644 --- a/frontend/apps/crates/components/src/module/_common/play/entry/state.rs +++ b/frontend/apps/crates/components/src/module/_common/play/entry/state.rs @@ -25,6 +25,7 @@ use std::future::Future; use std::marker::PhantomData; use std::rc::Rc; use std::str::FromStr; +use strong_id::StrongUuid; use utils::languages::Language; use utils::{iframe::*, prelude::*}; diff --git a/frontend/apps/crates/entry/home/src/home/actions.rs b/frontend/apps/crates/entry/home/src/home/actions.rs index 6672b62f72..548f8483a7 100644 --- a/frontend/apps/crates/entry/home/src/home/actions.rs +++ b/frontend/apps/crates/entry/home/src/home/actions.rs @@ -62,6 +62,7 @@ async fn fetch_profile(state: Rc) { } async fn search_async(state: Rc) { + log::info!("SEARCHING"); let search_state = SearchResults::new(&state, true); state .mode diff --git a/frontend/apps/crates/entry/home/src/home/search_results/dom.rs b/frontend/apps/crates/entry/home/src/home/search_results/dom.rs index 85a385ed10..0f50d82b7f 100644 --- a/frontend/apps/crates/entry/home/src/home/search_results/dom.rs +++ b/frontend/apps/crates/entry/home/src/home/search_results/dom.rs @@ -8,6 +8,7 @@ use super::state::SearchResults; impl SearchResults { pub fn render(self: &Rc) -> Dom { let state = self; + log::info!("RENDER SR"); let search_results_signal = |section: Rc| { // Ensure that jigs and resources are rendered until all requests have completed diff --git a/frontend/apps/crates/utils/Cargo.toml b/frontend/apps/crates/utils/Cargo.toml index 0fa35ccf93..581712044f 100644 --- a/frontend/apps/crates/utils/Cargo.toml +++ b/frontend/apps/crates/utils/Cargo.toml @@ -43,6 +43,7 @@ rgb = { workspace = true } lazy_static = { workspace = true } unicode-segmentation = { workspace = true } const_format = { workspace = true } +strong_id = { workspace = true } [features] debug_log = [] diff --git a/frontend/apps/crates/utils/src/metadata.rs b/frontend/apps/crates/utils/src/metadata.rs index c66fe77a31..0a3e0effbf 100644 --- a/frontend/apps/crates/utils/src/metadata.rs +++ b/frontend/apps/crates/utils/src/metadata.rs @@ -85,6 +85,7 @@ pub async fn get_metadata() -> Arc { let meta = future.await; let mut state = STATE.lock().unwrap_ji(); + log::info!("METADATA READY"); *state = State::Ready(meta.clone()); drop(state); diff --git a/frontend/apps/crates/utils/src/routes.rs b/frontend/apps/crates/utils/src/routes.rs index 4f4259192a..8f477ae3b6 100644 --- a/frontend/apps/crates/utils/src/routes.rs +++ b/frontend/apps/crates/utils/src/routes.rs @@ -20,6 +20,7 @@ use std::{ fmt::{Debug, Display}, str::FromStr, }; +use strong_id::StrongUuid; use uuid::Uuid; use wasm_bindgen::prelude::*; use web_sys::Url; @@ -71,19 +72,19 @@ pub struct SearchQueryParams { pub is_rated: Option, #[serde(default)] - #[serde(serialize_with = "shared::domain::ser::csv_encode_uuids")] + #[serde(serialize_with = "shared::domain::ser::csv_encode_strong_ids")] #[serde(deserialize_with = "shared::domain::ser::from_csv")] #[serde(skip_serializing_if = "Vec::is_empty")] pub age_ranges: Vec, #[serde(default)] - #[serde(serialize_with = "shared::domain::ser::csv_encode_uuids")] + #[serde(serialize_with = "shared::domain::ser::csv_encode_strong_ids")] #[serde(deserialize_with = "shared::domain::ser::from_csv")] #[serde(skip_serializing_if = "Vec::is_empty")] pub affiliations: Vec, #[serde(default)] - #[serde(serialize_with = "shared::domain::ser::csv_encode_uuids")] + #[serde(serialize_with = "shared::domain::ser::csv_encode_strong_ids")] #[serde(deserialize_with = "shared::domain::ser::from_csv")] #[serde(skip_serializing_if = "Vec::is_empty")] pub categories: Vec, diff --git a/shared/rust/Cargo.toml b/shared/rust/Cargo.toml index 66df1987a9..c2bbb25776 100644 --- a/shared/rust/Cargo.toml +++ b/shared/rust/Cargo.toml @@ -33,6 +33,7 @@ async-stripe = { version = "0.22.2", features = ["runtime-tokio-hyper-rustls"], macros = { path = "../macros" } unicode-segmentation = "1.8.0" derive_setters = "0.1.5" +strong_id = { version = "0.2.0" } # wasm wasm-bindgen = { version = "0.2.78", optional = true } diff --git a/shared/rust/src/domain.rs b/shared/rust/src/domain.rs index 8e70d3774d..7abfea7f57 100644 --- a/shared/rust/src/domain.rs +++ b/shared/rust/src/domain.rs @@ -28,49 +28,52 @@ macro_rules! into_i16_index { /// wrap_uuid! { /// /// Represents a My ID /// #[serde(rename_all = "camelCase")] -/// pub struct MyId +/// pub struct MyId("my_id") /// } /// ``` macro_rules! wrap_uuid { ( $(#[$outer:meta])* - $vis:vis struct $t:ident + $vis:vis struct $t:ident$(($prefix:literal))? ) => { - #[derive(Copy, Clone, Debug, Eq, PartialEq, Serialize, Deserialize, PathPart, Hash)] - $(#[$outer])* - #[cfg_attr(feature = "backend", derive(sqlx::Type))] - #[cfg_attr(feature = "backend", sqlx(transparent))] - $vis struct $t(pub uuid::Uuid); - - impl From<$t> for uuid::Uuid { - fn from(t: $t) -> Self { - t.0 - } + ::strong_id::strong_uuid! { + #[derive(PathPart)] + $(#[$outer])* + #[cfg_attr(feature = "backend", derive(sqlx::Type))] + #[cfg_attr(feature = "backend", sqlx(transparent))] + $vis struct $t(pub Uuid$( => $prefix)?) } - impl std::fmt::Display for $t { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{}", self.0) - } - } + impl ::serde::Serialize for $t { + fn serialize(&self, serializer: S) -> Result + where + S: ::serde::Serializer, + { + serializer.serialize_str(&self.to_string()) + } + } - impl std::str::FromStr for $t { - type Err = uuid::Error; + impl<'de> ::serde::Deserialize<'de> for $t { + fn deserialize(deserializer: D) -> Result + where + D: ::serde::Deserializer<'de>, + { - #[inline] - fn from_str(value: &str) -> Result { - Ok(Self(uuid::Uuid::from_str(value)?)) - } - } + let str_value = String::deserialize(deserializer)?; - impl $t { - /// Creates a wrapped UUID from a 128 bit value - #[inline] - #[must_use] - $vis const fn from_u128(v: u128) -> Self { - Self(uuid::Uuid::from_u128(v)) - } - } + Ok(match str_value.parse::() { + Ok(id) => id, + Err(error) => { + // Try to decode Uuid + let uuid = str_value.parse::<::uuid::Uuid>().map_err(|_| { + ::serde::de::Error::custom(error.to_string()) + })?; + + Self(uuid) + } + }) + } + } } } @@ -112,7 +115,10 @@ pub mod auth { } use chrono::Utc; -use ser::{csv_encode_i16_indices, csv_encode_uuids, deserialize_optional_field, from_csv}; +use ser::{ + csv_encode_i16_indices, csv_encode_strong_ids, csv_encode_uuids, deserialize_optional_field, + from_csv, +}; use serde::{Deserialize, Serialize}; use std::fmt::{Display, Formatter}; use uuid::Uuid; diff --git a/shared/rust/src/domain/additional_resource.rs b/shared/rust/src/domain/additional_resource.rs index f29dfc8d37..8a21e30fe9 100644 --- a/shared/rust/src/domain/additional_resource.rs +++ b/shared/rust/src/domain/additional_resource.rs @@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize}; wrap_uuid! { /// Wrapper type around [`Uuid`](Uuid), represents the ID of an additional resource. - pub struct AdditionalResourceId + pub struct AdditionalResourceId("ar") } #[derive(Serialize, Deserialize, Debug, Clone)] diff --git a/shared/rust/src/domain/animation.rs b/shared/rust/src/domain/animation.rs index 4bb609e228..f5a42c8897 100644 --- a/shared/rust/src/domain/animation.rs +++ b/shared/rust/src/domain/animation.rs @@ -33,7 +33,7 @@ impl AnimationKind { wrap_uuid! { /// Wrapper type around [`Uuid`], represents the ID of an animation. - pub struct AnimationId + pub struct AnimationId("anim") } make_path_parts!(AnimationGetPath => "/v1/animation/{}" => AnimationId); diff --git a/shared/rust/src/domain/audio.rs b/shared/rust/src/domain/audio.rs index 2e0a04e8bf..cbb3108d80 100644 --- a/shared/rust/src/domain/audio.rs +++ b/shared/rust/src/domain/audio.rs @@ -65,7 +65,7 @@ pub mod user { wrap_uuid! { /// Wrapper type around [`Uuid`](Uuid), represents the ID of an audio file. - pub struct AudioId + pub struct AudioId("aud") } /// Represents different kinds of audio. diff --git a/shared/rust/src/domain/billing.rs b/shared/rust/src/domain/billing.rs index e84f13c9ac..c1d9177393 100644 --- a/shared/rust/src/domain/billing.rs +++ b/shared/rust/src/domain/billing.rs @@ -126,7 +126,7 @@ pub enum PaymentMethodType { wrap_uuid! { /// Local payment method ID - pub struct PaymentMethodId + pub struct PaymentMethodId("pm") } /// Payment method @@ -285,7 +285,7 @@ impl From for SubscriptionStatus { wrap_uuid! { /// Local subscription ID - pub struct SubscriptionId + pub struct SubscriptionId("sub") } /// An existing subscription for a customer @@ -628,7 +628,7 @@ impl TrialPeriod { wrap_uuid! { /// Local charge ID - pub struct ChargeId + pub struct ChargeId("ch") } /// A charge to a customer for a subscription @@ -650,7 +650,7 @@ pub struct Charge { wrap_uuid! { /// Local subscription plan ID - pub struct PlanId + pub struct PlanId("plan") } /// A subscription plan @@ -723,7 +723,7 @@ make_path_parts!(CreateSetupIntentPath => "/v1/billing/payment-method"); wrap_uuid! { /// Account ID - pub struct AccountId + pub struct AccountId("acc") } /// A billing account @@ -778,7 +778,7 @@ pub struct UserAccountSummary { wrap_uuid! { /// Wrapper type around [`Uuid`], represents the ID of a School. - pub struct SchoolId + pub struct SchoolId("sch") } /// A school profile. @@ -846,7 +846,7 @@ pub struct AccountUser { wrap_uuid! { /// Wrapper type around [`Uuid`], represents the ID of a School Name. - pub struct SchoolNameId + pub struct SchoolNameId("sn") } make_path_parts!(SchoolNamePath => "/v1/school-name"); diff --git a/shared/rust/src/domain/category.rs b/shared/rust/src/domain/category.rs index f59566aba9..183463c977 100644 --- a/shared/rust/src/domain/category.rs +++ b/shared/rust/src/domain/category.rs @@ -11,7 +11,7 @@ wrap_uuid! { /// Wrapper type around [`Uuid`], represents the ID of a category. /// /// [`Uuid`]: ../../uuid/struct.Uuid.html - pub struct CategoryId + pub struct CategoryId("cat") } #[derive(Serialize, Deserialize, Debug)] @@ -105,9 +105,9 @@ pub struct GetCategoryRequest { // the backend _could_ transmute the `CategoryId`s into `Uuid`s, but that's `unsafe`. /// The exact ids to be included in the response. #[serde(default)] - #[serde(serialize_with = "super::csv_encode_uuids")] + #[serde(serialize_with = "super::csv_encode_strong_ids")] #[serde(deserialize_with = "super::from_csv")] - pub ids: Vec, + pub ids: Vec, /// Which direction to follow the tree. #[serde(default)] diff --git a/shared/rust/src/domain/circle.rs b/shared/rust/src/domain/circle.rs index 7e6a7ac0d2..f88eeca99c 100644 --- a/shared/rust/src/domain/circle.rs +++ b/shared/rust/src/domain/circle.rs @@ -11,8 +11,7 @@ use super::{asset::UserOrMe, image::ImageId, user::UserId}; wrap_uuid! { /// Wrapper type around [`Uuid`], represents the ID of a Circle. - #[serde(rename_all = "camelCase")] - pub struct CircleId + pub struct CircleId("cir") } /// The response returned when a request for `GET`ing a Circle is successful. @@ -101,7 +100,7 @@ pub struct CircleBrowseQuery { /// creator of circles /// The hits per page to be returned #[serde(default)] - #[serde(serialize_with = "super::csv_encode_uuids")] + #[serde(serialize_with = "super::csv_encode_strong_ids")] #[serde(deserialize_with = "super::from_csv")] #[serde(skip_serializing_if = "Vec::is_empty")] pub users: Vec, diff --git a/shared/rust/src/domain/course.rs b/shared/rust/src/domain/course.rs index 11f4c3ee15..eb8ee5ab4b 100644 --- a/shared/rust/src/domain/course.rs +++ b/shared/rust/src/domain/course.rs @@ -22,7 +22,7 @@ pub mod unit; wrap_uuid! { /// Wrapper type around [`Uuid`], represents the ID of a Course. - pub struct CourseId + pub struct CourseId("course") } make_path_parts!(CourseCreatePath => "/v1/course"); @@ -289,7 +289,7 @@ pub struct CourseBrowseQuery { /// Optionally filter by `additional resources` #[serde(default)] - #[serde(serialize_with = "super::csv_encode_uuids")] + #[serde(serialize_with = "super::csv_encode_strong_ids")] #[serde(deserialize_with = "super::from_csv")] #[serde(skip_serializing_if = "Vec::is_empty")] pub resource_types: Vec, @@ -378,14 +378,14 @@ pub struct CourseSearchQuery { /// Optionally filter by `additional resources` #[serde(default)] - #[serde(serialize_with = "super::csv_encode_uuids")] + #[serde(serialize_with = "super::csv_encode_strong_ids")] #[serde(deserialize_with = "super::from_csv")] #[serde(skip_serializing_if = "Vec::is_empty")] pub resource_types: Vec, /// Optionally filter by `categories` #[serde(default)] - #[serde(serialize_with = "super::csv_encode_uuids")] + #[serde(serialize_with = "super::csv_encode_strong_ids")] #[serde(deserialize_with = "super::from_csv")] #[serde(skip_serializing_if = "Vec::is_empty")] pub categories: Vec, diff --git a/shared/rust/src/domain/course/unit.rs b/shared/rust/src/domain/course/unit.rs index 151f96a6cc..c4b00c51b3 100644 --- a/shared/rust/src/domain/course/unit.rs +++ b/shared/rust/src/domain/course/unit.rs @@ -13,7 +13,7 @@ use super::CourseId; wrap_uuid! { /// Wrapper type around [`Uuid`](Uuid), represents the ID of a Course Unit. - pub struct CourseUnitId + pub struct CourseUnitId("cu") } #[derive(Serialize, Deserialize, Debug, Clone)] diff --git a/shared/rust/src/domain/image.rs b/shared/rust/src/domain/image.rs index 8fe8029cf9..23d01ca95f 100644 --- a/shared/rust/src/domain/image.rs +++ b/shared/rust/src/domain/image.rs @@ -63,7 +63,7 @@ wrap_uuid! { /// Wrapper type around [`Uuid`], represents the ID of a image. /// /// [`Uuid`]: ../../uuid/struct.Uuid.html - pub struct ImageId + pub struct ImageId("img") } make_path_parts!(ImageCreatePath => "/v1/image"); @@ -183,28 +183,28 @@ pub struct ImageSearchQuery { /// Optionally filter by `image_styles` #[serde(default)] - #[serde(serialize_with = "super::csv_encode_uuids")] + #[serde(serialize_with = "super::csv_encode_strong_ids")] #[serde(deserialize_with = "super::from_csv")] #[serde(skip_serializing_if = "Vec::is_empty")] pub styles: Vec, /// Optionally filter by `age_ranges` #[serde(default)] - #[serde(serialize_with = "super::csv_encode_uuids")] + #[serde(serialize_with = "super::csv_encode_strong_ids")] #[serde(deserialize_with = "super::from_csv")] #[serde(skip_serializing_if = "Vec::is_empty")] pub age_ranges: Vec, /// Optionally filter by `affiliations` #[serde(default)] - #[serde(serialize_with = "super::csv_encode_uuids")] + #[serde(serialize_with = "super::csv_encode_strong_ids")] #[serde(deserialize_with = "super::from_csv")] #[serde(skip_serializing_if = "Vec::is_empty")] pub affiliations: Vec, /// Optionally filter by `categories` #[serde(default)] - #[serde(serialize_with = "super::csv_encode_uuids")] + #[serde(serialize_with = "super::csv_encode_strong_ids")] #[serde(deserialize_with = "super::from_csv")] #[serde(skip_serializing_if = "Vec::is_empty")] pub categories: Vec, diff --git a/shared/rust/src/domain/jig.rs b/shared/rust/src/domain/jig.rs index 635c2e48e4..b311fe887a 100644 --- a/shared/rust/src/domain/jig.rs +++ b/shared/rust/src/domain/jig.rs @@ -29,7 +29,7 @@ use crate::{api::endpoints::PathPart, domain::module::body::ThemeId}; wrap_uuid! { /// Wrapper type around [`Uuid`], represents the ID of a JIG. - pub struct JigId + pub struct JigId("jig") } make_path_parts!(JigCreatePath => "/v1/jig"); @@ -613,7 +613,7 @@ pub struct JigBrowseQuery { /// Optionally filter by `additional resources` #[serde(default)] - #[serde(serialize_with = "super::csv_encode_uuids")] + #[serde(serialize_with = "super::csv_encode_strong_ids")] #[serde(deserialize_with = "super::from_csv")] #[serde(skip_serializing_if = "Vec::is_empty")] pub resource_types: Vec, @@ -663,7 +663,7 @@ pub struct JigSearchQuery { /// /// Note: Currently does nothing #[serde(default)] - #[serde(serialize_with = "super::csv_encode_uuids")] + #[serde(serialize_with = "super::csv_encode_strong_ids")] #[serde(deserialize_with = "super::from_csv")] #[serde(skip_serializing_if = "Vec::is_empty")] pub age_ranges: Vec, @@ -672,21 +672,21 @@ pub struct JigSearchQuery { /// /// Note: Currently does nothing #[serde(default)] - #[serde(serialize_with = "super::csv_encode_uuids")] + #[serde(serialize_with = "super::csv_encode_strong_ids")] #[serde(deserialize_with = "super::from_csv")] #[serde(skip_serializing_if = "Vec::is_empty")] pub affiliations: Vec, /// Optionally filter by `additional resources` #[serde(default)] - #[serde(serialize_with = "super::csv_encode_uuids")] + #[serde(serialize_with = "super::csv_encode_strong_ids")] #[serde(deserialize_with = "super::from_csv")] #[serde(skip_serializing_if = "Vec::is_empty")] pub resource_types: Vec, /// Optionally filter by `categories` #[serde(default)] - #[serde(serialize_with = "super::csv_encode_uuids")] + #[serde(serialize_with = "super::csv_encode_strong_ids")] #[serde(deserialize_with = "super::from_csv")] #[serde(skip_serializing_if = "Vec::is_empty")] pub categories: Vec, diff --git a/shared/rust/src/domain/jig/curation.rs b/shared/rust/src/domain/jig/curation.rs index 17cbc89766..fb205b3b85 100644 --- a/shared/rust/src/domain/jig/curation.rs +++ b/shared/rust/src/domain/jig/curation.rs @@ -10,7 +10,7 @@ use super::{report::JigReport, JigId}; wrap_uuid! { /// Wrapper type around [`Uuid`](Uuid), represents the ID of a curation comment. - pub struct CommentId + pub struct CommentId("jig_com") } make_path_parts!(JigCurationPath => "/v1/jig/{}/curation" => JigId); diff --git a/shared/rust/src/domain/jig/report.rs b/shared/rust/src/domain/jig/report.rs index c39745ee56..e5af6fa478 100644 --- a/shared/rust/src/domain/jig/report.rs +++ b/shared/rust/src/domain/jig/report.rs @@ -11,7 +11,7 @@ use super::JigId; wrap_uuid! { /// Wrapper type around [`Uuid`](Uuid), represents the ID of a curation comment. - pub struct ReportId + pub struct ReportId("jig_rep") } make_path_parts!(GetJigReportPath => "/v1/jig/{}/report/{}" => JigId, ReportId); diff --git a/shared/rust/src/domain/meta.rs b/shared/rust/src/domain/meta.rs index f005e104a0..eaaae5352e 100644 --- a/shared/rust/src/domain/meta.rs +++ b/shared/rust/src/domain/meta.rs @@ -8,42 +8,37 @@ use crate::api::endpoints::PathPart; wrap_uuid! { /// Wrapper type around [`Uuid`], represents [`ImageStyle::id`]. - pub struct ImageStyleId + pub struct ImageStyleId("img_style") } wrap_uuid! { /// Wrapper type around [`Uuid`], represents [`AnimationStyle::id`]. - pub struct AnimationStyleId + pub struct AnimationStyleId("anim_style") } wrap_uuid! { /// Wrapper type around [`Uuid`], represents [`AudioStyle::id`]. Note: not yet implemented - pub struct AudioStyleId + pub struct AudioStyleId("aud_style") } wrap_uuid! { /// Wrapper type around [`Uuid`], represents [`AgeRange::id`]. - pub struct AgeRangeId + pub struct AgeRangeId("age_range") } wrap_uuid! { /// Wrapper type around [`Uuid`], represents [`Affiliation::id`]. - pub struct AffiliationId + pub struct AffiliationId("aff") } wrap_uuid! { /// Wrapper type around [`Uuid`], represents [`AdditionalResource::id`]. - pub struct ResourceTypeId + pub struct ResourceTypeId("res_type") } wrap_uuid! { /// Wrapper type around [`Uuid`], represents [`Subject::id`]. - pub struct SubjectId -} - -wrap_uuid! { - /// Wrapper type around [`Uuid`], represents [`Report::id`]. - pub struct ReportId + pub struct SubjectId("subject") } /// Wrapper type around [`i16`](std::i16), represents the index of an image tag. diff --git a/shared/rust/src/domain/module.rs b/shared/rust/src/domain/module.rs index 39f5dd18c6..6abe0fe679 100644 --- a/shared/rust/src/domain/module.rs +++ b/shared/rust/src/domain/module.rs @@ -16,8 +16,7 @@ wrap_uuid! { /// Wrapper type around [`Uuid`](Uuid), represents the **unique ID** of a module. /// /// This uniquely identifies a module. There is no other module that shares this ID. - #[serde(rename_all = "camelCase")] - pub struct ModuleId + pub struct ModuleId("mod") } /// Represents the various kinds of data a module can represent. diff --git a/shared/rust/src/domain/pdf.rs b/shared/rust/src/domain/pdf.rs index aec501710a..72ea303640 100644 --- a/shared/rust/src/domain/pdf.rs +++ b/shared/rust/src/domain/pdf.rs @@ -63,7 +63,7 @@ pub mod user { wrap_uuid! { /// Wrapper type around [`Uuid`](Uuid), represents the ID of an Pdf file. - pub struct PdfId + pub struct PdfId("pdf") } /// Response for getting a single Pdf file. diff --git a/shared/rust/src/domain/playlist.rs b/shared/rust/src/domain/playlist.rs index d2329d423a..9b13618c0c 100644 --- a/shared/rust/src/domain/playlist.rs +++ b/shared/rust/src/domain/playlist.rs @@ -19,7 +19,7 @@ use super::{ wrap_uuid! { /// Wrapper type around [`Uuid`], represents the ID of a Playlist. - pub struct PlaylistId + pub struct PlaylistId("pl") } make_path_parts!(PlaylistCreatePath => "/v1/playlist"); @@ -300,7 +300,7 @@ pub struct PlaylistBrowseQuery { /// Optionally filter by `additional resources` #[serde(default)] - #[serde(serialize_with = "super::csv_encode_uuids")] + #[serde(serialize_with = "super::csv_encode_strong_ids")] #[serde(deserialize_with = "super::from_csv")] #[serde(skip_serializing_if = "Vec::is_empty")] pub resource_types: Vec, @@ -381,7 +381,7 @@ pub struct PlaylistSearchQuery { /// /// Note: Currently does nothing #[serde(default)] - #[serde(serialize_with = "super::csv_encode_uuids")] + #[serde(serialize_with = "super::csv_encode_strong_ids")] #[serde(deserialize_with = "super::from_csv")] #[serde(skip_serializing_if = "Vec::is_empty")] pub age_ranges: Vec, @@ -390,28 +390,28 @@ pub struct PlaylistSearchQuery { /// /// Note: Currently does nothing #[serde(default)] - #[serde(serialize_with = "super::csv_encode_uuids")] + #[serde(serialize_with = "super::csv_encode_strong_ids")] #[serde(deserialize_with = "super::from_csv")] #[serde(skip_serializing_if = "Vec::is_empty")] pub affiliations: Vec, /// Optionally filter by `additional resources` #[serde(default)] - #[serde(serialize_with = "super::csv_encode_uuids")] + #[serde(serialize_with = "super::csv_encode_strong_ids")] #[serde(deserialize_with = "super::from_csv")] #[serde(skip_serializing_if = "Vec::is_empty")] pub resource_types: Vec, /// Optionally filter by `categories` #[serde(default)] - #[serde(serialize_with = "super::csv_encode_uuids")] + #[serde(serialize_with = "super::csv_encode_strong_ids")] #[serde(deserialize_with = "super::from_csv")] #[serde(skip_serializing_if = "Vec::is_empty")] pub categories: Vec, /// Optionally filter by `items` #[serde(default)] - #[serde(serialize_with = "super::csv_encode_uuids")] + #[serde(serialize_with = "super::csv_encode_strong_ids")] #[serde(deserialize_with = "super::from_csv")] #[serde(skip_serializing_if = "Vec::is_empty")] pub items: Vec, diff --git a/shared/rust/src/domain/resource.rs b/shared/rust/src/domain/resource.rs index 36fe7f34a8..604ce925da 100644 --- a/shared/rust/src/domain/resource.rs +++ b/shared/rust/src/domain/resource.rs @@ -23,7 +23,7 @@ use super::{ wrap_uuid! { /// Wrapper type around [`Uuid`], represents the ID of a Resource. - pub struct ResourceId + pub struct ResourceId("res") } make_path_parts!(ResourceCreatePath => "/v1/resource"); @@ -267,7 +267,7 @@ pub struct ResourceBrowseQuery { /// Optionally filter by `additional resources` #[serde(default)] - #[serde(serialize_with = "super::csv_encode_uuids")] + #[serde(serialize_with = "super::csv_encode_strong_ids")] #[serde(deserialize_with = "super::from_csv")] #[serde(skip_serializing_if = "Vec::is_empty")] pub resource_types: Vec, @@ -323,7 +323,7 @@ pub struct ResourceSearchQuery { /// /// Note: Currently does nothing #[serde(default)] - #[serde(serialize_with = "super::csv_encode_uuids")] + #[serde(serialize_with = "super::csv_encode_strong_ids")] #[serde(deserialize_with = "super::from_csv")] #[serde(skip_serializing_if = "Vec::is_empty")] pub age_ranges: Vec, @@ -332,21 +332,21 @@ pub struct ResourceSearchQuery { /// /// Note: Currently does nothing #[serde(default)] - #[serde(serialize_with = "super::csv_encode_uuids")] + #[serde(serialize_with = "super::csv_encode_strong_ids")] #[serde(deserialize_with = "super::from_csv")] #[serde(skip_serializing_if = "Vec::is_empty")] pub affiliations: Vec, /// Optionally filter by `additional resources` #[serde(default)] - #[serde(serialize_with = "super::csv_encode_uuids")] + #[serde(serialize_with = "super::csv_encode_strong_ids")] #[serde(deserialize_with = "super::from_csv")] #[serde(skip_serializing_if = "Vec::is_empty")] pub resource_types: Vec, /// Optionally filter by `categories` #[serde(default)] - #[serde(serialize_with = "super::csv_encode_uuids")] + #[serde(serialize_with = "super::csv_encode_strong_ids")] #[serde(deserialize_with = "super::from_csv")] #[serde(skip_serializing_if = "Vec::is_empty")] pub categories: Vec, diff --git a/shared/rust/src/domain/resource/curation.rs b/shared/rust/src/domain/resource/curation.rs index c8e2b297da..3bada7e73c 100644 --- a/shared/rust/src/domain/resource/curation.rs +++ b/shared/rust/src/domain/resource/curation.rs @@ -9,7 +9,7 @@ use super::{report::ResourceReport, ResourceId, UserId}; wrap_uuid! { /// Wrapper type around [`Uuid`](Uuid), represents the ID of a curation comment. - pub struct CommentId + pub struct CommentId("res_com") } make_path_parts!(ResourceCurationPath => "/v1/resource/{}/curation" => ResourceId); diff --git a/shared/rust/src/domain/resource/report.rs b/shared/rust/src/domain/resource/report.rs index 23555df1a2..e0b818af0e 100644 --- a/shared/rust/src/domain/resource/report.rs +++ b/shared/rust/src/domain/resource/report.rs @@ -11,7 +11,7 @@ use super::ResourceId; wrap_uuid! { /// Wrapper type around [`Uuid`](Uuid), represents the ID of a curation comment. - pub struct ReportId + pub struct ReportId("res_rep") } make_path_parts!(GetResourceReportPath => "/v1/resource/{}/report/{}" => ResourceId, ReportId); diff --git a/shared/rust/src/domain/ser.rs b/shared/rust/src/domain/ser.rs index cd25cd3a0f..1d43c2b36c 100644 --- a/shared/rust/src/domain/ser.rs +++ b/shared/rust/src/domain/ser.rs @@ -6,6 +6,7 @@ use std::{ marker::PhantomData, str::FromStr, }; +use strong_id::StrongId; use uuid::Uuid; @@ -55,6 +56,26 @@ where serializer.serialize_str(&out) } +/// Serializes a slice of StrongIds into CSV format +/// +/// ## Note: +/// * Algolia takes CSV format arrays: https://www.algolia.com/doc/rest-api/search/#arrays +pub fn csv_encode_strong_ids, S>( + ids: &[T], + serializer: S, +) -> Result +where + S: serde::Serializer, +{ + let out = ids + .iter() + .map(|id| format!("{id}")) + .collect::>() + .join(","); + + serializer.serialize_str(&out) +} + /// ASSUMING this is only going to be used for resources identified by index, which is /// a non-negative integer which begins counting up from 0. /// diff --git a/shared/rust/src/domain/user.rs b/shared/rust/src/domain/user.rs index 8b6a54edda..e5d581b59a 100644 --- a/shared/rust/src/domain/user.rs +++ b/shared/rust/src/domain/user.rs @@ -19,7 +19,7 @@ pub mod public_user; wrap_uuid! { /// Wrapper type around [`Uuid`], represents the ID of a User. - pub struct UserId + pub struct UserId("user") } /// Represents a user's permissions. diff --git a/shared/rust/src/domain/user/public_user.rs b/shared/rust/src/domain/user/public_user.rs index 2e1cb4c4c4..f82f0d2e2c 100644 --- a/shared/rust/src/domain/user/public_user.rs +++ b/shared/rust/src/domain/user/public_user.rs @@ -4,7 +4,7 @@ use crate::{ api::endpoints::PathPart, domain::{ additional_resource::AdditionalResource, asset::UserOrMe, circle::CircleId, - csv_encode_uuids, from_csv, image::ImageId, user::UserId, + csv_encode_strong_ids, from_csv, image::ImageId, user::UserId, }, }; use macros::make_path_parts; @@ -115,7 +115,7 @@ pub struct UserBrowseQuery { /// Circle's that has user joined #[serde(default)] - #[serde(serialize_with = "csv_encode_uuids")] + #[serde(serialize_with = "csv_encode_strong_ids")] #[serde(deserialize_with = "from_csv")] #[serde(skip_serializing_if = "Vec::is_empty")] pub circles: Vec,