A better Rust ATProto crate

refactoring out the codegen binaries to change dep tree for code->lexicon path

Orual 7c7de622 b8978f16

+156 -75
+50 -4
Cargo.lock
··· 2288 2288 [[package]] 2289 2289 name = "jacquard-api" 2290 2290 version = "0.8.0" 2291 - source = "git+https://tangled.org/@nonbinary.computer/jacquard#46f8b7fef44831413798068a56771a1f52126301" 2291 + source = "git+https://tangled.org/@nonbinary.computer/jacquard#b8978f162ed3306519ec3155a5fd01fbda2390a3" 2292 2292 dependencies = [ 2293 2293 "bon", 2294 2294 "bytes", ··· 2378 2378 [[package]] 2379 2379 name = "jacquard-common" 2380 2380 version = "0.8.0" 2381 - source = "git+https://tangled.org/@nonbinary.computer/jacquard#46f8b7fef44831413798068a56771a1f52126301" 2381 + source = "git+https://tangled.org/@nonbinary.computer/jacquard#b8978f162ed3306519ec3155a5fd01fbda2390a3" 2382 2382 dependencies = [ 2383 2383 "base64 0.22.1", 2384 2384 "bon", ··· 2427 2427 [[package]] 2428 2428 name = "jacquard-derive" 2429 2429 version = "0.8.0" 2430 - source = "git+https://tangled.org/@nonbinary.computer/jacquard#46f8b7fef44831413798068a56771a1f52126301" 2430 + source = "git+https://tangled.org/@nonbinary.computer/jacquard#b8978f162ed3306519ec3155a5fd01fbda2390a3" 2431 2431 dependencies = [ 2432 2432 "proc-macro2", 2433 2433 "quote", ··· 2462 2462 [[package]] 2463 2463 name = "jacquard-identity" 2464 2464 version = "0.8.0" 2465 - source = "git+https://tangled.org/@nonbinary.computer/jacquard#46f8b7fef44831413798068a56771a1f52126301" 2465 + source = "git+https://tangled.org/@nonbinary.computer/jacquard#b8978f162ed3306519ec3155a5fd01fbda2390a3" 2466 2466 dependencies = [ 2467 2467 "bon", 2468 2468 "bytes", ··· 2483 2483 ] 2484 2484 2485 2485 [[package]] 2486 + name = "jacquard-lexgen" 2487 + version = "0.8.0" 2488 + dependencies = [ 2489 + "async-trait", 2490 + "clap", 2491 + "clap_complete", 2492 + "clap_mangen", 2493 + "glob", 2494 + "jacquard-api 0.8.0 (git+https://tangled.org/@nonbinary.computer/jacquard)", 2495 + "jacquard-common 0.8.0 (git+https://tangled.org/@nonbinary.computer/jacquard)", 2496 + "jacquard-identity 0.8.0 (git+https://tangled.org/@nonbinary.computer/jacquard)", 2497 + "jacquard-lexicon 0.8.0 (git+https://tangled.org/@nonbinary.computer/jacquard)", 2498 + "kdl", 2499 + "miette", 2500 + "reqwest", 2501 + "serde", 2502 + "serde_json", 2503 + "tempfile", 2504 + "thiserror 2.0.17", 2505 + "tokio", 2506 + "walkdir", 2507 + ] 2508 + 2509 + [[package]] 2486 2510 name = "jacquard-lexicon" 2487 2511 version = "0.8.0" 2512 + dependencies = [ 2513 + "glob", 2514 + "heck 0.5.0", 2515 + "jacquard-common 0.8.0", 2516 + "miette", 2517 + "prettyplease", 2518 + "proc-macro2", 2519 + "quote", 2520 + "serde", 2521 + "serde_json", 2522 + "serde_repr", 2523 + "serde_with", 2524 + "syn 2.0.108", 2525 + "tempfile", 2526 + "thiserror 2.0.17", 2527 + "walkdir", 2528 + ] 2529 + 2530 + [[package]] 2531 + name = "jacquard-lexicon" 2532 + version = "0.8.0" 2533 + source = "git+https://tangled.org/@nonbinary.computer/jacquard#b8978f162ed3306519ec3155a5fd01fbda2390a3" 2488 2534 dependencies = [ 2489 2535 "async-trait", 2490 2536 "clap",
+55
crates/jacquard-lexgen/Cargo.toml
··· 1 + [package] 2 + name = "jacquard-lexgen" 3 + description = "Lexicon fetching and code generation binaries for Jacquard" 4 + edition.workspace = true 5 + version.workspace = true 6 + authors.workspace = true 7 + repository.workspace = true 8 + keywords.workspace = true 9 + categories.workspace = true 10 + readme.workspace = true 11 + exclude.workspace = true 12 + license.workspace = true 13 + 14 + [[bin]] 15 + name = "jacquard-codegen" 16 + path = "src/bin/codegen.rs" 17 + 18 + [[bin]] 19 + name = "lex-fetch" 20 + path = "src/bin/lex_fetch.rs" 21 + 22 + [dependencies] 23 + async-trait = "0.1" 24 + clap.workspace = true 25 + glob = "0.3" 26 + jacquard-api = { version = "0.8", git = "https://tangled.org/@nonbinary.computer/jacquard" } 27 + jacquard-common = { version = "0.8", features = [ "reqwest-client" ], git = "https://tangled.org/@nonbinary.computer/jacquard" } 28 + jacquard-identity = { version = "0.8", git = "https://tangled.org/@nonbinary.computer/jacquard" } 29 + jacquard-lexicon = { version = "0.8", git = "https://tangled.org/@nonbinary.computer/jacquard" } 30 + kdl = "6" 31 + miette = { workspace = true, features = ["fancy"] } 32 + reqwest = { workspace = true, features = ["json", "http2", "system-proxy", "rustls-tls"] } 33 + serde.workspace = true 34 + serde_json.workspace = true 35 + tempfile = "3.23" 36 + thiserror.workspace = true 37 + tokio = { workspace = true, features = ["full"] } 38 + walkdir = "2.5" 39 + 40 + [dev-dependencies] 41 + tempfile = { version = "3.23.0" } 42 + 43 + [build-dependencies] 44 + clap.workspace = true 45 + clap_complete.workspace = true 46 + clap_mangen.workspace = true 47 + 48 + [package.metadata.binstall] 49 + pkg-url = "https://github.com/rsform/jacquard/releases/download/v{ version }/{ name }_{ target }_v{ version }{ archive-suffix }" 50 + bin-dir = "{ name }_{ target }_v{ version }/bin/{ bin }{ binary-ext }" 51 + pkg-fmt = "txz" 52 + 53 + [package.metadata.binstall.overrides.x86_64-pc-windows-gnu] 54 + pkg-fmt = "zip" 55 + bin-dir = "{ name }_{ target }_v{ version }/{ bin }{ binary-ext }"
+36
crates/jacquard-lexgen/src/lib.rs
··· 1 + //! # Lexicon fetching and code generation binaries for Jacquard 2 + //! 3 + //! This crate provides the tooling for fetching lexicon schemas from various sources 4 + //! and generating Rust code from them. 5 + //! 6 + //! ## Binaries 7 + //! 8 + //! ### lex-fetch 9 + //! 10 + //! Downloads lexicons from configured sources and runs the code generation pipeline: 11 + //! 12 + //! ```bash 13 + //! cargo run -p jacquard-lexgen --bin lex-fetch 14 + //! ``` 15 + //! 16 + //! Configuration lives in `lexicons.kdl` at the workspace root. 17 + //! 18 + //! ### jacquard-codegen 19 + //! 20 + //! Runs code generation on a local directory of lexicons: 21 + //! 22 + //! ```bash 23 + //! cargo run -p jacquard-lexgen --bin jacquard-codegen -- \ 24 + //! -i ./lexicons \ 25 + //! -o ./crates/jacquard-api/src 26 + //! ``` 27 + //! 28 + //! ## Modules 29 + //! 30 + //! - [`fetch`] - Ingests lexicons from git, atproto, http fetch, and other sources 31 + //! - [`cli`] - CLI argument parsing utilities 32 + 33 + pub mod cli; 34 + pub mod fetch; 35 + 36 + pub use fetch::{Config, Fetcher};
+1 -32
crates/jacquard-lexicon/Cargo.toml
··· 11 11 exclude.workspace = true 12 12 license.workspace = true 13 13 14 - [[bin]] 15 - name = "jacquard-codegen" 16 - path = "src/bin/codegen.rs" 17 - 18 - [[bin]] 19 - name = "lex-fetch" 20 - path = "src/bin/lex_fetch.rs" 21 - 22 14 [dependencies] 23 - async-trait = "0.1" 24 - clap.workspace = true 25 15 glob = "0.3" 26 16 heck.workspace = true 27 - #itertools.workspace = true 28 - jacquard-api = { version = "0.8", git = "https://tangled.org/@nonbinary.computer/jacquard" } 29 - jacquard-common = { version = "0.8", features = [ "reqwest-client" ], git = "https://tangled.org/@nonbinary.computer/jacquard" } 30 - jacquard-identity = { version = "0.8", git = "https://tangled.org/@nonbinary.computer/jacquard" } 31 - kdl = "6" 17 + jacquard-common = { version = "0.8", path = "../jacquard-common" } 32 18 miette = { workspace = true, features = ["fancy"] } 33 19 prettyplease.workspace = true 34 20 proc-macro2.workspace = true 35 21 quote.workspace = true 36 - reqwest = { workspace = true, features = ["json", "http2", "system-proxy", "rustls-tls"] } 37 22 serde.workspace = true 38 23 serde_json.workspace = true 39 24 serde_repr.workspace = true 40 25 serde_with.workspace = true 41 26 syn.workspace = true 42 - tempfile = "3.23" 43 27 thiserror.workspace = true 44 - tokio = { workspace = true, features = ["full"] } 45 28 walkdir = "2.5" 46 29 47 30 [dev-dependencies] 48 31 tempfile = { version = "3.23.0" } 49 - 50 - [build-dependencies] 51 - clap.workspace = true 52 - clap_complete.workspace = true 53 - clap_mangen.workspace = true 54 - 55 - [package.metadata.binstall] 56 - pkg-url = "https://github.com/rsform/jacquard/releases/download/v{ version }/{ name }_{ target }_v{ version }{ archive-suffix }" 57 - bin-dir = "{ name }_{ target }_v{ version }/bin/{ bin }{ binary-ext }" 58 - pkg-fmt = "txz" 59 - 60 - [package.metadata.binstall.overrides.x86_64-pc-windows-gnu] 61 - pkg-fmt = "zip" 62 - bin-dir = "{ name }_{ target }_v{ version }/{ bin }{ binary-ext }"
crates/jacquard-lexicon/build.rs crates/jacquard-lexgen/build.rs
+1 -1
crates/jacquard-lexicon/src/bin/codegen.rs crates/jacquard-lexgen/src/bin/codegen.rs
··· 1 1 use clap::Parser; 2 - use jacquard_lexicon::cli::CodegenArgs; 2 + use jacquard_lexgen::cli::CodegenArgs; 3 3 use jacquard_lexicon::codegen::CodeGenerator; 4 4 use jacquard_lexicon::corpus::LexiconCorpus; 5 5
+2 -2
crates/jacquard-lexicon/src/bin/lex_fetch.rs crates/jacquard-lexgen/src/bin/lex_fetch.rs
··· 1 1 use clap::Parser; 2 - use jacquard_lexicon::cli::LexFetchArgs; 2 + use jacquard_lexgen::cli::LexFetchArgs; 3 + use jacquard_lexgen::fetch::{Config, Fetcher}; 3 4 use jacquard_lexicon::codegen::CodeGenerator; 4 5 use jacquard_lexicon::corpus::LexiconCorpus; 5 - use jacquard_lexicon::fetch::{Config, Fetcher}; 6 6 use miette::{IntoDiagnostic, Result}; 7 7 use std::path::PathBuf; 8 8
crates/jacquard-lexicon/src/cli.rs crates/jacquard-lexgen/src/cli.rs
+1 -1
crates/jacquard-lexicon/src/fetch.rs crates/jacquard-lexgen/src/fetch.rs
··· 5 5 use jacquard_common::IntoStatic; 6 6 pub use sources::{LexiconSource, SourceType}; 7 7 8 - use crate::lexicon::LexiconDoc; 8 + use jacquard_lexicon::lexicon::LexiconDoc; 9 9 use miette::Result; 10 10 use std::collections::HashMap; 11 11
crates/jacquard-lexicon/src/fetch/config.rs crates/jacquard-lexgen/src/fetch/config.rs
+1 -1
crates/jacquard-lexicon/src/fetch/sources.rs crates/jacquard-lexgen/src/fetch/sources.rs
··· 13 13 pub use local::LocalSource; 14 14 pub use slices::SlicesSource; 15 15 16 - use crate::lexicon::LexiconDoc; 16 + use jacquard_lexicon::lexicon::LexiconDoc; 17 17 use miette::{IntoDiagnostic, Result}; 18 18 use std::collections::HashMap; 19 19 use std::future::Future;
+1 -1
crates/jacquard-lexicon/src/fetch/sources/atproto.rs crates/jacquard-lexgen/src/fetch/sources/atproto.rs
··· 1 1 use super::LexiconSource; 2 - use crate::lexicon::LexiconDoc; 2 + use jacquard_lexicon::lexicon::LexiconDoc; 3 3 use jacquard_api::com_atproto::repo::list_records::ListRecords; 4 4 use jacquard_common::IntoStatic; 5 5 use jacquard_common::types::ident::AtIdentifier;
+2 -1
crates/jacquard-lexicon/src/fetch/sources/git.rs crates/jacquard-lexgen/src/fetch/sources/git.rs
··· 1 1 use super::LexiconSource; 2 - use crate::{fetch::sources::parse_from_index_or_lexicon_file, lexicon::LexiconDoc}; 2 + use crate::fetch::sources::parse_from_index_or_lexicon_file; 3 3 use jacquard_common::IntoStatic; 4 + use jacquard_lexicon::lexicon::LexiconDoc; 4 5 use miette::{IntoDiagnostic, Result, miette}; 5 6 use std::collections::HashMap; 6 7 use tempfile::TempDir;
+1 -1
crates/jacquard-lexicon/src/fetch/sources/http.rs crates/jacquard-lexgen/src/fetch/sources/http.rs
··· 1 1 use super::LexiconSource; 2 - use crate::lexicon::LexiconDoc; 2 + use jacquard_lexicon::lexicon::LexiconDoc; 3 3 use jacquard_common::IntoStatic; 4 4 use miette::{Result, miette}; 5 5 use serde::Deserialize;
+1 -1
crates/jacquard-lexicon/src/fetch/sources/jsonfile.rs crates/jacquard-lexgen/src/fetch/sources/jsonfile.rs
··· 1 1 use super::LexiconSource; 2 - use crate::lexicon::LexiconDoc; 2 + use jacquard_lexicon::lexicon::LexiconDoc; 3 3 use jacquard_common::types::value::Data; 4 4 use jacquard_common::IntoStatic; 5 5 use miette::{IntoDiagnostic, Result};
+1 -1
crates/jacquard-lexicon/src/fetch/sources/local.rs crates/jacquard-lexgen/src/fetch/sources/local.rs
··· 1 1 use super::LexiconSource; 2 2 use crate::fetch::sources::parse_from_index_or_lexicon_file; 3 - use crate::lexicon::LexiconDoc; 3 + use jacquard_lexicon::lexicon::LexiconDoc; 4 4 use jacquard_common::IntoStatic; 5 5 use miette::{IntoDiagnostic, Result}; 6 6 use std::collections::HashMap;
+1 -1
crates/jacquard-lexicon/src/fetch/sources/slices.rs crates/jacquard-lexgen/src/fetch/sources/slices.rs
··· 1 1 use super::LexiconSource; 2 - use crate::lexicon::LexiconDoc; 2 + use jacquard_lexicon::lexicon::LexiconDoc; 3 3 use jacquard_common::IntoStatic; 4 4 use miette::{Result, miette}; 5 5 use serde::{Deserialize, Serialize};
+2 -28
crates/jacquard-lexicon/src/lib.rs
··· 1 1 //! # Lexicon schema parsing and Rust code generation for the Jacquard atproto ecosystem 2 2 //! 3 - //! This crate also provides lexicon fetching capabilitiees ofr 4 - //! 5 - //! ## Usage 6 - //! 7 - //! ### Fetch lexicons 8 - //! 9 - //! The `lex-fetch` binary downloads lexicons from configured sources and 10 - //! runs the code generation pipeline on them: 11 - //! 12 - //! ```bash 13 - //! cargo run -p jacquard-lexicon --bin lex-fetch 14 - //! ``` 15 - //! 16 - //! Configuration lives in `lexicons.kdl` at the workspace root. 17 - //! 18 - //! ### Generate Rust code 3 + //! This crate provides the core lexicon types and code generation infrastructure. 19 4 //! 20 - //! The `jacquard-codegen` binary can be pointed at a local directory to 21 - //! runs the code generation pipeline: 22 - //! 23 - //! ```bash 24 - //! cargo run -p jacquard-lexicon --bin jacquard-codegen -- \ 25 - //! -i ./lexicons \ 26 - //! -o ./crates/jacquard-api/src 27 - //! ``` 28 - //! 5 + //! For fetching lexicons and running the codegen binaries, see the `jacquard-lexgen` crate. 29 6 //! 30 7 //! ## Modules 31 8 //! ··· 33 10 //! - [`corpus`] - Lexicon corpus management and namespace organization 34 11 //! - [`lexicon`] - Schema parsing and validation 35 12 //! - [`union_registry`] - Tracks union types for collision detection 36 - //! - [`fetch`] - Ingests lexicons from git, atproto, http fetch, and other sources 37 13 //! - [`fs`] - Filesystem utilities for lexicon storage 38 14 39 - pub mod cli; 40 15 pub mod codegen; 41 16 pub mod corpus; 42 17 pub mod error; 43 - pub mod fetch; 44 18 pub mod fs; 45 19 pub mod lexicon; 46 20 pub mod union_registry;