Loading codegen/Cargo.toml +1 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ publish = false codegen-writer = "0.1.0" heck = "0.4.1" nugine-rust-utils = "0.1.2" numeric_cast = "0.2.1" regex = "1.8.1" serde = { version = "1.0.163", features = ["derive"] } serde_json = { version = "1.0.96", features = ["preserve_order"] } Loading codegen/src/aws_conv.rs +1 −0 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ use codegen_writer::glines; use heck::ToSnakeCase; use heck::ToUpperCamelCase; #[allow(clippy::too_many_lines)] pub fn codegen(ops: &Operations, rust_types: &RustTypes) { glines![ "//! Auto generated by `codegen/src/aws_conv.rs`", // Loading codegen/src/dto.rs +4 −6 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ pub fn to_type_name(shape_name: &str) -> &str { pub type RustTypes = BTreeMap<String, rust::Type>; #[deny(clippy::shadow_unrelated)] #[allow(clippy::too_many_lines)] pub fn collect_rust_types(model: &smithy::Model, ops: &Operations) -> RustTypes { let mut space: BTreeMap<String, rust::Type> = default(); let mut insert = |k: String, v: rust::Type| assert!(space.insert(k, v).is_none()); Loading Loading @@ -137,10 +138,7 @@ pub fn collect_rust_types(model: &smithy::Model, ops: &Operations) -> RustTypes let default_value = field.traits.default_value().map(o); let is_required = field.traits.required(); let is_op_input = rs_shape_name .strip_suffix("Request") .map(|op| ops.contains_key(op)) .unwrap_or(false); let is_op_input = rs_shape_name.strip_suffix("Request").map_or(false, |op| ops.contains_key(op)); let option_type = 'optional: { if field_type == "StreamingBlob" && default_value.as_ref().unwrap() == "" { Loading Loading @@ -185,7 +183,7 @@ pub fn collect_rust_types(model: &smithy::Model, ops: &Operations) -> RustTypes type_: field_type, doc: field.traits.doc().map(o), camel_name: field_name.to_owned(), camel_name: field_name.clone(), option_type, default_value, Loading Loading @@ -214,7 +212,7 @@ pub fn collect_rust_types(model: &smithy::Model, ops: &Operations) -> RustTypes let mut variants = Vec::new(); for (variant_name, variant) in &shape.members { let variant = rust::StructEnumVariant { name: variant_name.to_owned(), name: variant_name.clone(), type_: to_type_name(&variant.target).to_owned(), doc: variant.traits.doc().map(o), }; Loading codegen/src/error.rs +2 −1 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ fn collect_errors(model: &smithy::Model) -> Errors { let mut errors: BTreeMap<String, Error> = default(); let mut iter = error_code_doc.lines().map(|line| line.trim()); let mut iter = error_code_doc.lines().map(str::trim); while let Some(line) = iter.next() { let code = { let Some(cap) = pattern.captures(line) else { continue }; Loading Loading @@ -118,6 +118,7 @@ fn collect_errors(model: &smithy::Model) -> Errors { errors } #[allow(clippy::too_many_lines)] pub fn codegen(model: &smithy::Model) { let errors = collect_errors(model); Loading codegen/src/main.rs +9 −2 Original line number Diff line number Diff line #![forbid(unsafe_code)] #![deny( clippy::all, // clippy::must_use_candidate, // clippy::semicolon_if_nothing_returned, // clippy::pedantic, // )] #![warn( clippy::dbg_macro, // )] #![allow( clippy::single_match_else, // clippy::wildcard_imports, clippy::match_same_arms, )] mod rust; Loading Loading
codegen/Cargo.toml +1 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ publish = false codegen-writer = "0.1.0" heck = "0.4.1" nugine-rust-utils = "0.1.2" numeric_cast = "0.2.1" regex = "1.8.1" serde = { version = "1.0.163", features = ["derive"] } serde_json = { version = "1.0.96", features = ["preserve_order"] } Loading
codegen/src/aws_conv.rs +1 −0 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ use codegen_writer::glines; use heck::ToSnakeCase; use heck::ToUpperCamelCase; #[allow(clippy::too_many_lines)] pub fn codegen(ops: &Operations, rust_types: &RustTypes) { glines![ "//! Auto generated by `codegen/src/aws_conv.rs`", // Loading
codegen/src/dto.rs +4 −6 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ pub fn to_type_name(shape_name: &str) -> &str { pub type RustTypes = BTreeMap<String, rust::Type>; #[deny(clippy::shadow_unrelated)] #[allow(clippy::too_many_lines)] pub fn collect_rust_types(model: &smithy::Model, ops: &Operations) -> RustTypes { let mut space: BTreeMap<String, rust::Type> = default(); let mut insert = |k: String, v: rust::Type| assert!(space.insert(k, v).is_none()); Loading Loading @@ -137,10 +138,7 @@ pub fn collect_rust_types(model: &smithy::Model, ops: &Operations) -> RustTypes let default_value = field.traits.default_value().map(o); let is_required = field.traits.required(); let is_op_input = rs_shape_name .strip_suffix("Request") .map(|op| ops.contains_key(op)) .unwrap_or(false); let is_op_input = rs_shape_name.strip_suffix("Request").map_or(false, |op| ops.contains_key(op)); let option_type = 'optional: { if field_type == "StreamingBlob" && default_value.as_ref().unwrap() == "" { Loading Loading @@ -185,7 +183,7 @@ pub fn collect_rust_types(model: &smithy::Model, ops: &Operations) -> RustTypes type_: field_type, doc: field.traits.doc().map(o), camel_name: field_name.to_owned(), camel_name: field_name.clone(), option_type, default_value, Loading Loading @@ -214,7 +212,7 @@ pub fn collect_rust_types(model: &smithy::Model, ops: &Operations) -> RustTypes let mut variants = Vec::new(); for (variant_name, variant) in &shape.members { let variant = rust::StructEnumVariant { name: variant_name.to_owned(), name: variant_name.clone(), type_: to_type_name(&variant.target).to_owned(), doc: variant.traits.doc().map(o), }; Loading
codegen/src/error.rs +2 −1 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ fn collect_errors(model: &smithy::Model) -> Errors { let mut errors: BTreeMap<String, Error> = default(); let mut iter = error_code_doc.lines().map(|line| line.trim()); let mut iter = error_code_doc.lines().map(str::trim); while let Some(line) = iter.next() { let code = { let Some(cap) = pattern.captures(line) else { continue }; Loading Loading @@ -118,6 +118,7 @@ fn collect_errors(model: &smithy::Model) -> Errors { errors } #[allow(clippy::too_many_lines)] pub fn codegen(model: &smithy::Model) { let errors = collect_errors(model); Loading
codegen/src/main.rs +9 −2 Original line number Diff line number Diff line #![forbid(unsafe_code)] #![deny( clippy::all, // clippy::must_use_candidate, // clippy::semicolon_if_nothing_returned, // clippy::pedantic, // )] #![warn( clippy::dbg_macro, // )] #![allow( clippy::single_match_else, // clippy::wildcard_imports, clippy::match_same_arms, )] mod rust; Loading