A better Rust ATProto crate

fixing the feature gates and stuff

+107 -123
+70 -112
Cargo.lock
··· 1880 1880 "libc", 1881 1881 "percent-encoding", 1882 1882 "pin-project-lite", 1883 - "socket2 0.6.0", 1883 + "socket2 0.5.10", 1884 1884 "system-configuration", 1885 1885 "tokio", 1886 1886 "tower-service", ··· 1900 1900 "js-sys", 1901 1901 "log", 1902 1902 "wasm-bindgen", 1903 - "windows-core 0.62.1", 1903 + "windows-core", 1904 1904 ] 1905 1905 1906 1906 [[package]] ··· 2186 2186 ] 2187 2187 2188 2188 [[package]] 2189 - name = "itertools" 2190 - version = "0.14.0" 2191 - source = "registry+https://github.com/rust-lang/crates.io-index" 2192 - checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" 2193 - dependencies = [ 2194 - "either", 2195 - ] 2196 - 2197 - [[package]] 2198 2189 name = "itoa" 2199 2190 version = "1.0.15" 2200 2191 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 2202 2193 2203 2194 [[package]] 2204 2195 name = "jacquard" 2205 - version = "0.5.4" 2196 + version = "0.6.0" 2206 2197 dependencies = [ 2207 2198 "bon", 2208 2199 "bytes", ··· 2211 2202 "getrandom 0.2.16", 2212 2203 "http", 2213 2204 "image", 2214 - "jacquard-api 0.5.5", 2215 - "jacquard-common 0.5.4", 2216 - "jacquard-derive 0.5.4", 2217 - "jacquard-identity 0.5.3", 2205 + "jacquard-api 0.6.0", 2206 + "jacquard-common 0.6.0", 2207 + "jacquard-derive 0.6.0", 2208 + "jacquard-identity 0.6.0", 2218 2209 "jacquard-oauth", 2219 2210 "jose-jwk", 2220 2211 "miette", ··· 2239 2230 2240 2231 [[package]] 2241 2232 name = "jacquard-api" 2242 - version = "0.5.1" 2243 - source = "git+https://tangled.org/@nonbinary.computer/jacquard#77915fd4920b282b4b1342749dcdad9dce30cadf" 2233 + version = "0.6.0" 2244 2234 dependencies = [ 2245 2235 "bon", 2246 2236 "bytes", 2247 - "jacquard-common 0.5.1", 2248 - "jacquard-derive 0.5.1", 2237 + "jacquard-common 0.6.0", 2238 + "jacquard-derive 0.6.0", 2249 2239 "miette", 2250 2240 "serde", 2241 + "serde_ipld_dagcbor", 2251 2242 "thiserror 2.0.17", 2252 2243 ] 2253 2244 2254 2245 [[package]] 2255 2246 name = "jacquard-api" 2256 - version = "0.5.5" 2247 + version = "0.6.0" 2248 + source = "git+https://tangled.org/@nonbinary.computer/jacquard#8546eeba588760175f40467a8788236140c26b56" 2257 2249 dependencies = [ 2258 2250 "bon", 2259 2251 "bytes", 2260 - "jacquard-common 0.5.4", 2261 - "jacquard-derive 0.5.4", 2252 + "jacquard-common 0.6.0 (git+https://tangled.org/@nonbinary.computer/jacquard)", 2253 + "jacquard-derive 0.6.0 (git+https://tangled.org/@nonbinary.computer/jacquard)", 2262 2254 "miette", 2263 2255 "serde", 2264 2256 "serde_ipld_dagcbor", ··· 2267 2259 2268 2260 [[package]] 2269 2261 name = "jacquard-axum" 2270 - version = "0.5.2" 2262 + version = "0.6.0" 2271 2263 dependencies = [ 2272 2264 "axum", 2273 2265 "axum-macros", ··· 2276 2268 "bytes", 2277 2269 "chrono", 2278 2270 "jacquard", 2279 - "jacquard-common 0.5.4", 2280 - "jacquard-derive 0.5.4", 2281 - "jacquard-identity 0.5.3", 2271 + "jacquard-common 0.6.0", 2272 + "jacquard-derive 0.6.0", 2273 + "jacquard-identity 0.6.0", 2282 2274 "k256", 2283 2275 "miette", 2284 2276 "multibase", ··· 2298 2290 2299 2291 [[package]] 2300 2292 name = "jacquard-common" 2301 - version = "0.5.1" 2302 - source = "git+https://tangled.org/@nonbinary.computer/jacquard#77915fd4920b282b4b1342749dcdad9dce30cadf" 2293 + version = "0.6.0" 2303 2294 dependencies = [ 2304 - "async-trait", 2305 2295 "base64 0.22.1", 2306 2296 "bon", 2307 2297 "bytes", 2308 2298 "chrono", 2299 + "ciborium", 2309 2300 "cid", 2301 + "ed25519-dalek", 2302 + "futures", 2303 + "futures-lite", 2304 + "genawaiter", 2305 + "getrandom 0.3.4", 2310 2306 "http", 2311 2307 "ipld-core", 2308 + "k256", 2312 2309 "langtag", 2313 2310 "miette", 2314 2311 "multibase", 2315 2312 "multihash", 2313 + "n0-future", 2316 2314 "ouroboros", 2315 + "p256", 2317 2316 "rand 0.9.2", 2318 2317 "regex", 2319 2318 "reqwest", ··· 2321 2320 "serde_html_form", 2322 2321 "serde_ipld_dagcbor", 2323 2322 "serde_json", 2324 - "serde_with", 2323 + "signature", 2325 2324 "smol_str", 2326 2325 "thiserror 2.0.17", 2327 2326 "tokio", 2327 + "tokio-tungstenite-wasm", 2328 + "tokio-util", 2329 + "tracing", 2328 2330 "trait-variant", 2329 2331 "url", 2332 + "zstd", 2330 2333 ] 2331 2334 2332 2335 [[package]] 2333 2336 name = "jacquard-common" 2334 - version = "0.5.4" 2337 + version = "0.6.0" 2338 + source = "git+https://tangled.org/@nonbinary.computer/jacquard#8546eeba588760175f40467a8788236140c26b56" 2335 2339 dependencies = [ 2336 2340 "base64 0.22.1", 2337 2341 "bon", 2338 2342 "bytes", 2339 2343 "chrono", 2340 - "ciborium", 2341 2344 "cid", 2342 - "ed25519-dalek", 2343 - "futures", 2344 - "futures-lite", 2345 2345 "genawaiter", 2346 2346 "getrandom 0.3.4", 2347 2347 "http", ··· 2351 2351 "miette", 2352 2352 "multibase", 2353 2353 "multihash", 2354 - "n0-future", 2355 2354 "ouroboros", 2356 2355 "p256", 2357 2356 "rand 0.9.2", ··· 2365 2364 "smol_str", 2366 2365 "thiserror 2.0.17", 2367 2366 "tokio", 2368 - "tokio-tungstenite-wasm", 2369 2367 "tokio-util", 2370 - "tracing", 2371 2368 "trait-variant", 2372 2369 "url", 2373 - "zstd", 2374 2370 ] 2375 2371 2376 2372 [[package]] 2377 2373 name = "jacquard-derive" 2378 - version = "0.5.1" 2379 - source = "git+https://tangled.org/@nonbinary.computer/jacquard#77915fd4920b282b4b1342749dcdad9dce30cadf" 2374 + version = "0.6.0" 2380 2375 dependencies = [ 2381 - "heck 0.5.0", 2382 - "itertools 0.14.0", 2383 - "prettyplease", 2376 + "jacquard-common 0.6.0", 2384 2377 "proc-macro2", 2385 2378 "quote", 2386 2379 "serde", 2387 2380 "serde_json", 2388 - "serde_repr", 2389 - "serde_with", 2390 2381 "syn 2.0.106", 2391 2382 ] 2392 2383 2393 2384 [[package]] 2394 2385 name = "jacquard-derive" 2395 - version = "0.5.4" 2386 + version = "0.6.0" 2387 + source = "git+https://tangled.org/@nonbinary.computer/jacquard#8546eeba588760175f40467a8788236140c26b56" 2396 2388 dependencies = [ 2397 - "jacquard-common 0.5.4", 2398 2389 "proc-macro2", 2399 2390 "quote", 2400 - "serde", 2401 - "serde_json", 2402 2391 "syn 2.0.106", 2403 2392 ] 2404 2393 2405 2394 [[package]] 2406 2395 name = "jacquard-identity" 2407 - version = "0.5.1" 2408 - source = "git+https://tangled.org/@nonbinary.computer/jacquard#77915fd4920b282b4b1342749dcdad9dce30cadf" 2396 + version = "0.6.0" 2409 2397 dependencies = [ 2410 - "async-trait", 2411 2398 "bon", 2412 2399 "bytes", 2400 + "hickory-resolver", 2413 2401 "http", 2414 - "jacquard-api 0.5.1", 2415 - "jacquard-common 0.5.1", 2402 + "jacquard-api 0.6.0", 2403 + "jacquard-common 0.6.0", 2416 2404 "miette", 2405 + "n0-future", 2417 2406 "percent-encoding", 2418 2407 "reqwest", 2419 2408 "serde", ··· 2421 2410 "serde_json", 2422 2411 "thiserror 2.0.17", 2423 2412 "tokio", 2413 + "tracing", 2414 + "trait-variant", 2424 2415 "url", 2425 2416 "urlencoding", 2426 2417 ] 2427 2418 2428 2419 [[package]] 2429 2420 name = "jacquard-identity" 2430 - version = "0.5.3" 2421 + version = "0.6.0" 2422 + source = "git+https://tangled.org/@nonbinary.computer/jacquard#8546eeba588760175f40467a8788236140c26b56" 2431 2423 dependencies = [ 2432 2424 "bon", 2433 2425 "bytes", 2434 - "hickory-resolver", 2435 2426 "http", 2436 - "jacquard-api 0.5.5", 2437 - "jacquard-common 0.5.4", 2427 + "jacquard-api 0.6.0 (git+https://tangled.org/@nonbinary.computer/jacquard)", 2428 + "jacquard-common 0.6.0 (git+https://tangled.org/@nonbinary.computer/jacquard)", 2438 2429 "miette", 2439 - "n0-future", 2440 2430 "percent-encoding", 2441 2431 "reqwest", 2442 2432 "serde", ··· 2444 2434 "serde_json", 2445 2435 "thiserror 2.0.17", 2446 2436 "tokio", 2447 - "tracing", 2448 2437 "trait-variant", 2449 2438 "url", 2450 2439 "urlencoding", ··· 2452 2441 2453 2442 [[package]] 2454 2443 name = "jacquard-lexicon" 2455 - version = "0.5.4" 2444 + version = "0.6.0" 2456 2445 dependencies = [ 2457 2446 "async-trait", 2458 2447 "clap", 2459 2448 "glob", 2460 2449 "heck 0.5.0", 2461 - "jacquard-api 0.5.1", 2462 - "jacquard-common 0.5.1", 2463 - "jacquard-identity 0.5.1", 2450 + "jacquard-api 0.6.0 (git+https://tangled.org/@nonbinary.computer/jacquard)", 2451 + "jacquard-common 0.6.0 (git+https://tangled.org/@nonbinary.computer/jacquard)", 2452 + "jacquard-identity 0.6.0 (git+https://tangled.org/@nonbinary.computer/jacquard)", 2464 2453 "kdl", 2465 2454 "miette", 2466 2455 "prettyplease", ··· 2480 2469 2481 2470 [[package]] 2482 2471 name = "jacquard-oauth" 2483 - version = "0.5.4" 2472 + version = "0.6.0" 2484 2473 dependencies = [ 2485 2474 "base64 0.22.1", 2486 2475 "bytes", ··· 2488 2477 "dashmap", 2489 2478 "elliptic-curve", 2490 2479 "http", 2491 - "jacquard-common 0.5.4", 2492 - "jacquard-identity 0.5.3", 2480 + "jacquard-common 0.6.0", 2481 + "jacquard-identity 0.6.0", 2493 2482 "jose-jwa", 2494 2483 "jose-jwk", 2495 2484 "miette", ··· 3524 3513 "quinn-udp", 3525 3514 "rustc-hash", 3526 3515 "rustls", 3527 - "socket2 0.6.0", 3516 + "socket2 0.5.10", 3528 3517 "thiserror 2.0.17", 3529 3518 "tokio", 3530 3519 "tracing", ··· 3561 3550 "cfg_aliases", 3562 3551 "libc", 3563 3552 "once_cell", 3564 - "socket2 0.6.0", 3553 + "socket2 0.5.10", 3565 3554 "tracing", 3566 3555 "windows-sys 0.60.2", 3567 3556 ] ··· 3660 3649 "built", 3661 3650 "cfg-if", 3662 3651 "interpolate_name", 3663 - "itertools 0.12.1", 3652 + "itertools", 3664 3653 "libc", 3665 3654 "libfuzzer-sys", 3666 3655 "log", ··· 5466 5455 source = "registry+https://github.com/rust-lang/crates.io-index" 5467 5456 checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" 5468 5457 dependencies = [ 5469 - "windows-sys 0.61.1", 5458 + "windows-sys 0.48.0", 5470 5459 ] 5471 5460 5472 5461 [[package]] ··· 5482 5471 checksum = "9babd3a767a4c1aef6900409f85f5d53ce2544ccdfaa86dad48c91782c6d6893" 5483 5472 dependencies = [ 5484 5473 "windows-collections", 5485 - "windows-core 0.61.2", 5474 + "windows-core", 5486 5475 "windows-future", 5487 5476 "windows-link 0.1.3", 5488 5477 "windows-numerics", ··· 5494 5483 source = "registry+https://github.com/rust-lang/crates.io-index" 5495 5484 checksum = "3beeceb5e5cfd9eb1d76b381630e82c4241ccd0d27f1a39ed41b2760b255c5e8" 5496 5485 dependencies = [ 5497 - "windows-core 0.61.2", 5486 + "windows-core", 5498 5487 ] 5499 5488 5500 5489 [[package]] ··· 5506 5495 "windows-implement", 5507 5496 "windows-interface", 5508 5497 "windows-link 0.1.3", 5509 - "windows-result 0.3.4", 5510 - "windows-strings 0.4.2", 5511 - ] 5512 - 5513 - [[package]] 5514 - name = "windows-core" 5515 - version = "0.62.1" 5516 - source = "registry+https://github.com/rust-lang/crates.io-index" 5517 - checksum = "6844ee5416b285084d3d3fffd743b925a6c9385455f64f6d4fa3031c4c2749a9" 5518 - dependencies = [ 5519 - "windows-implement", 5520 - "windows-interface", 5521 - "windows-link 0.2.0", 5522 - "windows-result 0.4.0", 5523 - "windows-strings 0.5.0", 5498 + "windows-result", 5499 + "windows-strings", 5524 5500 ] 5525 5501 5526 5502 [[package]] ··· 5529 5505 source = "registry+https://github.com/rust-lang/crates.io-index" 5530 5506 checksum = "fc6a41e98427b19fe4b73c550f060b59fa592d7d686537eebf9385621bfbad8e" 5531 5507 dependencies = [ 5532 - "windows-core 0.61.2", 5508 + "windows-core", 5533 5509 "windows-link 0.1.3", 5534 5510 "windows-threading", 5535 5511 ] ··· 5574 5550 source = "registry+https://github.com/rust-lang/crates.io-index" 5575 5551 checksum = "9150af68066c4c5c07ddc0ce30421554771e528bde427614c61038bc2c92c2b1" 5576 5552 dependencies = [ 5577 - "windows-core 0.61.2", 5553 + "windows-core", 5578 5554 "windows-link 0.1.3", 5579 5555 ] 5580 5556 ··· 5585 5561 checksum = "5b8a9ed28765efc97bbc954883f4e6796c33a06546ebafacbabee9696967499e" 5586 5562 dependencies = [ 5587 5563 "windows-link 0.1.3", 5588 - "windows-result 0.3.4", 5589 - "windows-strings 0.4.2", 5564 + "windows-result", 5565 + "windows-strings", 5590 5566 ] 5591 5567 5592 5568 [[package]] ··· 5599 5575 ] 5600 5576 5601 5577 [[package]] 5602 - name = "windows-result" 5603 - version = "0.4.0" 5604 - source = "registry+https://github.com/rust-lang/crates.io-index" 5605 - checksum = "7084dcc306f89883455a206237404d3eaf961e5bd7e0f312f7c91f57eb44167f" 5606 - dependencies = [ 5607 - "windows-link 0.2.0", 5608 - ] 5609 - 5610 - [[package]] 5611 5578 name = "windows-strings" 5612 5579 version = "0.4.2" 5613 5580 source = "registry+https://github.com/rust-lang/crates.io-index" 5614 5581 checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57" 5615 5582 dependencies = [ 5616 5583 "windows-link 0.1.3", 5617 - ] 5618 - 5619 - [[package]] 5620 - name = "windows-strings" 5621 - version = "0.5.0" 5622 - source = "registry+https://github.com/rust-lang/crates.io-index" 5623 - checksum = "7218c655a553b0bed4426cf54b20d7ba363ef543b52d515b3e48d7fd55318dda" 5624 - dependencies = [ 5625 - "windows-link 0.2.0", 5626 5584 ] 5627 5585 5628 5586 [[package]]
+1 -1
crates/jacquard-api/Cargo.toml
··· 37 37 lexicon_community = ["community_lexicon", "my_skylights", "com_whtwnd", "social_psky", "blue_linkat", "minimal"] 38 38 ufos = [ "moe_karashiiro", "dev_regnault", "buzz_bookhive", "uk_ewancroft", "win_tomo_x", "dev_fudgeu", "dev_ocbwoy3", "blog_pckt", "net_bnewbold", "club_stellz", "dev_baileytownsend", "net_aftertheinter", "org_devcon","org_robocracy", "garden_lexicon", "social_clippr", "social_grain", "social_pmsky", "com_crabdance", "app_blebbit", "app_ocho", "uk_skyblur", "us_polhem", "blue_atplane", "net_mmatt", "minimal", "app_rocksky"] 39 39 40 - streaming = [] 40 + streaming = ["jacquard-common/websocket"] 41 41 42 42 # --- generated --- 43 43 # Generated namespace features
+7 -6
crates/jacquard-api/src/com_atproto/label.rs
··· 6 6 // Any manual changes will be overwritten on the next regeneration. 7 7 8 8 pub mod query_labels; 9 + #[cfg(feature = "streaming")] // manually added temporarily 9 10 pub mod subscribe_labels; 10 11 11 12 /// Metadata tag on an atproto resource (eg, repo or record). ··· 18 19 PartialEq, 19 20 Eq, 20 21 jacquard_derive::IntoStatic, 21 - bon::Builder 22 + bon::Builder, 22 23 )] 23 24 #[serde(rename_all = "camelCase")] 24 25 pub struct Label<'a> { ··· 188 189 PartialEq, 189 190 Eq, 190 191 jacquard_derive::IntoStatic, 191 - bon::Builder 192 + bon::Builder, 192 193 )] 193 194 #[serde(rename_all = "camelCase")] 194 195 pub struct LabelValueDefinition<'a> { ··· 227 228 PartialEq, 228 229 Eq, 229 230 jacquard_derive::IntoStatic, 230 - bon::Builder 231 + bon::Builder, 231 232 )] 232 233 #[serde(rename_all = "camelCase")] 233 234 pub struct LabelValueDefinitionStrings<'a> { ··· 253 254 PartialEq, 254 255 Eq, 255 256 jacquard_derive::IntoStatic, 256 - Default 257 + Default, 257 258 )] 258 259 #[serde(rename_all = "camelCase")] 259 260 pub struct SelfLabel<'a> { ··· 272 273 PartialEq, 273 274 Eq, 274 275 jacquard_derive::IntoStatic, 275 - bon::Builder 276 + bon::Builder, 276 277 )] 277 278 #[serde(rename_all = "camelCase")] 278 279 pub struct SelfLabels<'a> { 279 280 #[serde(borrow)] 280 281 pub values: Vec<crate::com_atproto::label::SelfLabel<'a>>, 281 - } 282 + }
+2 -1
crates/jacquard-api/src/com_atproto/sync.rs
··· 20 20 pub mod list_repos_by_collection; 21 21 pub mod notify_of_update; 22 22 pub mod request_crawl; 23 + #[cfg(feature = "streaming")] // manually added temporarily 23 24 pub mod subscribe_repos; 24 25 25 26 #[derive(Debug, Clone, PartialEq, Eq, Hash)] ··· 111 112 HostStatus::Other(v) => HostStatus::Other(v.into_static()), 112 113 } 113 114 } 114 - } 115 + }
+1 -1
crates/jacquard-lexicon/Cargo.toml
··· 25 25 glob = "0.3" 26 26 heck.workspace = true 27 27 #itertools.workspace = true 28 - jacquard-api = { version = "0.5", git = "https://tangled.org/@nonbinary.computer/jacquard" } 28 + jacquard-api = { version = "0.6", git = "https://tangled.org/@nonbinary.computer/jacquard" } 29 29 jacquard-common = { version = "0.6", features = [ "reqwest-client" ], git = "https://tangled.org/@nonbinary.computer/jacquard" } 30 30 jacquard-identity = { version = "0.6", git = "https://tangled.org/@nonbinary.computer/jacquard" } 31 31 kdl = "6"
+9 -1
crates/jacquard-lexicon/src/codegen.rs
··· 19 19 /// Track namespace dependencies (namespace -> set of namespaces it depends on) 20 20 namespace_deps: 21 21 std::cell::RefCell<std::collections::HashMap<String, std::collections::HashSet<String>>>, 22 + /// Track which file paths contain subscription endpoints 23 + subscription_files: std::cell::RefCell<std::collections::HashSet<std::path::PathBuf>>, 22 24 } 23 25 24 26 impl<'c> CodeGenerator<'c> { ··· 28 30 corpus, 29 31 root_module: root_module.into(), 30 32 namespace_deps: std::cell::RefCell::new(std::collections::HashMap::new()), 33 + subscription_files: std::cell::RefCell::new(std::collections::HashSet::new()), 31 34 } 32 35 } 33 36 ··· 166 169 nsid, 167 170 None::<String>, 168 171 )), 169 - LexUserType::XrpcSubscription(sub) => self.generate_subscription(nsid, def_name, sub), 172 + LexUserType::XrpcSubscription(sub) => { 173 + // Track this file as containing a subscription 174 + let file_path = self.nsid_to_file_path(nsid); 175 + self.subscription_files.borrow_mut().insert(file_path); 176 + self.generate_subscription(nsid, def_name, sub) 177 + } 170 178 } 171 179 } 172 180 }
+17 -1
crates/jacquard-lexicon/src/codegen/output.rs
··· 46 46 &self, 47 47 file_map: &BTreeMap<std::path::PathBuf, (TokenStream, Option<String>)>, 48 48 defs_only: &BTreeMap<std::path::PathBuf, (TokenStream, Option<String>)>, 49 + subscription_files: &HashSet<std::path::PathBuf>, 49 50 ) -> BTreeMap<std::path::PathBuf, (TokenStream, Option<String>)> { 50 51 // Track what modules each directory needs to declare 51 52 // Key: directory path, Value: set of module names (file stems) ··· 100 101 .iter() 101 102 .map(|name| { 102 103 let ident = make_ident(name); 104 + 105 + // Check if this module is a subscription endpoint 106 + let mut module_path = dir.clone(); 107 + module_path.push(format!("{}.rs", name)); 108 + let is_subscription = subscription_files.contains(&module_path); 109 + 103 110 if is_root { 104 111 // Top-level modules get feature gates 105 112 quote! { 106 113 #[cfg(feature = #name)] 114 + pub mod #ident; 115 + } 116 + } else if is_subscription { 117 + // Subscription modules get streaming feature gate 118 + quote! { 119 + #[cfg(feature = "streaming")] 107 120 pub mod #ident; 108 121 } 109 122 } else { ··· 134 147 let defs_files = self.generate_all()?; 135 148 let mut all_files = defs_files.clone(); 136 149 150 + // Get subscription files for feature gating 151 + let subscription_files = self.subscription_files.borrow(); 152 + 137 153 // Generate module tree iteratively until no new files appear 138 154 loop { 139 - let module_map = self.generate_module_tree(&all_files, &defs_files); 155 + let module_map = self.generate_module_tree(&all_files, &defs_files, &subscription_files); 140 156 let old_count = all_files.len(); 141 157 142 158 // Merge new module files