A better Rust ATProto crate
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

codegen fixes

Orual ce692323 1f831994

+22 -14
+7 -5
Cargo.lock
··· 2290 [[package]] 2291 name = "jacquard-api" 2292 version = "0.8.0" 2293 - source = "git+https://tangled.org/@nonbinary.computer/jacquard#1c7fc38baf8f100875ba178c19a255e34727b116" 2294 dependencies = [ 2295 "bon", 2296 "bytes", 2297 "jacquard-common 0.8.0 (git+https://tangled.org/@nonbinary.computer/jacquard)", 2298 "jacquard-derive 0.8.0 (git+https://tangled.org/@nonbinary.computer/jacquard)", 2299 "miette", 2300 "serde", 2301 "serde_ipld_dagcbor", 2302 "thiserror 2.0.17", 2303 ] 2304 2305 [[package]] ··· 2380 [[package]] 2381 name = "jacquard-common" 2382 version = "0.8.0" 2383 - source = "git+https://tangled.org/@nonbinary.computer/jacquard#1c7fc38baf8f100875ba178c19a255e34727b116" 2384 dependencies = [ 2385 "base64 0.22.1", 2386 "bon", ··· 2433 [[package]] 2434 name = "jacquard-derive" 2435 version = "0.8.0" 2436 - source = "git+https://tangled.org/@nonbinary.computer/jacquard#1c7fc38baf8f100875ba178c19a255e34727b116" 2437 dependencies = [ 2438 "heck 0.5.0", 2439 "jacquard-lexicon 0.8.0 (git+https://tangled.org/@nonbinary.computer/jacquard)", ··· 2470 [[package]] 2471 name = "jacquard-identity" 2472 version = "0.8.0" 2473 - source = "git+https://tangled.org/@nonbinary.computer/jacquard#1c7fc38baf8f100875ba178c19a255e34727b116" 2474 dependencies = [ 2475 "bon", 2476 "bytes", ··· 2544 [[package]] 2545 name = "jacquard-lexicon" 2546 version = "0.8.0" 2547 - source = "git+https://tangled.org/@nonbinary.computer/jacquard#1c7fc38baf8f100875ba178c19a255e34727b116" 2548 dependencies = [ 2549 "glob", 2550 "heck 0.5.0",
··· 2290 [[package]] 2291 name = "jacquard-api" 2292 version = "0.8.0" 2293 + source = "git+https://tangled.org/@nonbinary.computer/jacquard#1f831994b95d87fe938d4e7b2213e44bbd18e2bd" 2294 dependencies = [ 2295 "bon", 2296 "bytes", 2297 "jacquard-common 0.8.0 (git+https://tangled.org/@nonbinary.computer/jacquard)", 2298 "jacquard-derive 0.8.0 (git+https://tangled.org/@nonbinary.computer/jacquard)", 2299 + "jacquard-lexicon 0.8.0 (git+https://tangled.org/@nonbinary.computer/jacquard)", 2300 "miette", 2301 "serde", 2302 "serde_ipld_dagcbor", 2303 "thiserror 2.0.17", 2304 + "unicode-segmentation", 2305 ] 2306 2307 [[package]] ··· 2382 [[package]] 2383 name = "jacquard-common" 2384 version = "0.8.0" 2385 + source = "git+https://tangled.org/@nonbinary.computer/jacquard#1f831994b95d87fe938d4e7b2213e44bbd18e2bd" 2386 dependencies = [ 2387 "base64 0.22.1", 2388 "bon", ··· 2435 [[package]] 2436 name = "jacquard-derive" 2437 version = "0.8.0" 2438 + source = "git+https://tangled.org/@nonbinary.computer/jacquard#1f831994b95d87fe938d4e7b2213e44bbd18e2bd" 2439 dependencies = [ 2440 "heck 0.5.0", 2441 "jacquard-lexicon 0.8.0 (git+https://tangled.org/@nonbinary.computer/jacquard)", ··· 2472 [[package]] 2473 name = "jacquard-identity" 2474 version = "0.8.0" 2475 + source = "git+https://tangled.org/@nonbinary.computer/jacquard#1f831994b95d87fe938d4e7b2213e44bbd18e2bd" 2476 dependencies = [ 2477 "bon", 2478 "bytes", ··· 2546 [[package]] 2547 name = "jacquard-lexicon" 2548 version = "0.8.0" 2549 + source = "git+https://tangled.org/@nonbinary.computer/jacquard#1f831994b95d87fe938d4e7b2213e44bbd18e2bd" 2550 dependencies = [ 2551 "glob", 2552 "heck 0.5.0",
+12 -7
crates/jacquard-lexicon/src/codegen/schema_impl.rs
··· 13 /// 14 /// Takes the original lexicon doc and type metadata to generate a complete 15 /// impl with const literal and validation code. 16 - pub fn generate_schema_impl(type_name: &str, doc: &LexiconDoc, has_lifetime: bool) -> TokenStream { 17 let nsid = doc.id.as_ref(); 18 19 // Generate lifetime parameter ··· 26 // Generate the lexicon doc literal using existing doc_to_tokens 27 let doc_literal = doc_to_tokens::doc_to_tokens(doc); 28 29 - // Extract validation checks from lexicon doc 30 - let validation_checks = extract_validation_checks(doc); 31 32 // Generate validation code using existing validations_to_tokens 33 let validation_code = doc_to_tokens::validations_to_tokens(&validation_checks); ··· 57 /// 58 /// Walks the lexicon structure and builds ValidationCheck structs for all 59 /// constraint fields (max_length, max_graphemes, minimum, maximum, etc.) 60 - fn extract_validation_checks(doc: &LexiconDoc) -> Vec<ValidationCheck> { 61 let mut checks = Vec::new(); 62 63 - // Get main def 64 - if let Some(main_def) = doc.defs.get("main") { 65 - match main_def { 66 LexUserType::Record(rec) => { 67 match &rec.record { 68 LexRecordRecord::Object(obj) => {
··· 13 /// 14 /// Takes the original lexicon doc and type metadata to generate a complete 15 /// impl with const literal and validation code. 16 + pub fn generate_schema_impl( 17 + type_name: &str, 18 + doc: &LexiconDoc, 19 + def_name: &str, 20 + has_lifetime: bool, 21 + ) -> TokenStream { 22 let nsid = doc.id.as_ref(); 23 24 // Generate lifetime parameter ··· 31 // Generate the lexicon doc literal using existing doc_to_tokens 32 let doc_literal = doc_to_tokens::doc_to_tokens(doc); 33 34 + // Extract validation checks from lexicon doc for the specific def 35 + let validation_checks = extract_validation_checks(doc, def_name); 36 37 // Generate validation code using existing validations_to_tokens 38 let validation_code = doc_to_tokens::validations_to_tokens(&validation_checks); ··· 62 /// 63 /// Walks the lexicon structure and builds ValidationCheck structs for all 64 /// constraint fields (max_length, max_graphemes, minimum, maximum, etc.) 65 + fn extract_validation_checks(doc: &LexiconDoc, def_name: &str) -> Vec<ValidationCheck> { 66 let mut checks = Vec::new(); 67 68 + // Get the specified def 69 + if let Some(def) = doc.defs.get(def_name) { 70 + match def { 71 LexUserType::Record(rec) => { 72 match &rec.record { 73 LexRecordRecord::Object(obj) => {
+3 -2
crates/jacquard-lexicon/src/codegen/structs.rs
··· 219 // Generate LexiconSchema impl from original lexicon 220 let lex_doc = self.corpus.get(nsid).expect("nsid exists in corpus"); 221 let schema_impl = 222 - super::schema_impl::generate_schema_impl(&type_name, lex_doc, true); 223 224 Ok(quote! { 225 #struct_def ··· 341 342 // Generate LexiconSchema impl from original lexicon 343 let lex_doc = self.corpus.get(nsid).expect("nsid exists in corpus"); 344 - let schema_impl = super::schema_impl::generate_schema_impl(&type_name, lex_doc, true); 345 346 Ok(quote! { 347 #struct_def
··· 219 // Generate LexiconSchema impl from original lexicon 220 let lex_doc = self.corpus.get(nsid).expect("nsid exists in corpus"); 221 let schema_impl = 222 + super::schema_impl::generate_schema_impl(&type_name, lex_doc, "main", true); 223 224 Ok(quote! { 225 #struct_def ··· 341 342 // Generate LexiconSchema impl from original lexicon 343 let lex_doc = self.corpus.get(nsid).expect("nsid exists in corpus"); 344 + let schema_impl = 345 + super::schema_impl::generate_schema_impl(&type_name, lex_doc, def_name, true); 346 347 Ok(quote! { 348 #struct_def