#[non_exhaustive]pub struct GeneratedCode {
pub query_fn: Option<String>,
pub row_struct: Option<String>,
pub model_struct: Option<String>,
pub enum_def: Option<String>,
pub nested_struct_defs: Vec<NestedStructDef>,
}Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.query_fn: Option<String>§row_struct: Option<String>§model_struct: Option<String>§enum_def: Option<String>§nested_struct_defs: Vec<NestedStructDef>Nested-aggregate struct definitions this query needs, one entry per
scythe_core::analyzer::NestedStructInfo the backend opted into.
Kept out of model_struct (where composites go) because these have
to be deduplicated across the queries written into one file: two
queries can legitimately derive the same struct name, and emitting
the definition twice is E0428 in Rust and a redeclaration in every
other target. model_struct is already a rendered blob with no
identity attached, so the name has to survive alongside the code for
the writer to dedupe on. See scythe-cli’s generate_for_backend.
Implementations§
Source§impl GeneratedCode
impl GeneratedCode
Sourcepub fn build(init: impl FnOnce(&mut Self)) -> Self
pub fn build(init: impl FnOnce(&mut Self)) -> Self
Build a GeneratedCode from Default, assigning fields inside
init.
#[non_exhaustive] forbids a struct literal outside this crate –
including with ..Default::default() – so downstream crates
(scythe-cli, and anyone embedding the generator) have no other way
to construct one. Mirrors
scythe_core::analyzer::AnalyzedQuery::build, and keeping
construction a single expression avoids clippy’s
field_reassign_with_default.
use scythe_codegen::GeneratedCode;
let code = GeneratedCode::build(|c| {
c.query_fn = Some("fn get_user() {}".to_string());
});
assert!(code.row_struct.is_none());Trait Implementations§
Source§impl Clone for GeneratedCode
impl Clone for GeneratedCode
Source§fn clone(&self) -> GeneratedCode
fn clone(&self) -> GeneratedCode
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more