Unverified Commit a6134063 authored by Nugine's avatar Nugine
Browse files

deps: codegen-writer v0.2.0

parent b30302b3
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@ edition = "2021"
publish = false

[dependencies]
codegen-writer = "0.1.0"
codegen-writer = "0.2.0"
heck = "0.4.1"
nugine-rust-utils = "0.3.1"
numeric_cast = "0.2.1"
+4 −4
Original line number Diff line number Diff line
@@ -13,10 +13,10 @@ 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`", //
        "",
        "use super::*;",
        "",
        "//! Auto generated by `codegen/src/aws_conv.rs`"
        ""
        "use super::*;"
        ""
    ];

    for (name, rust_type) in rust_types {
+20 −20
Original line number Diff line number Diff line
@@ -10,18 +10,18 @@ use heck::ToSnakeCase;

pub fn codegen(ops: &Operations, rust_types: &RustTypes) {
    glines![
        "//! Auto generated by `codegen/src/aws_proxy.rs`",
        "",
        "use super::*;",
        "",
        "use crate::conv::{try_from_aws, try_into_aws};",
        "",
        "use s3s::S3;",
        "use s3s::{S3Request, S3Response};",
        "use s3s::S3Result;",
        "",
        "use tracing::debug;",
        "",
        "//! Auto generated by `codegen/src/aws_proxy.rs`"
        ""
        "use super::*;"
        ""
        "use crate::conv::{try_from_aws, try_into_aws};"
        ""
        "use s3s::S3;"
        "use s3s::{S3Request, S3Response};"
        "use s3s::S3Result;"
        ""
        "use tracing::debug;"
        ""
    ];

    g!("#[async_trait::async_trait]");
@@ -85,14 +85,14 @@ pub fn codegen(ops: &Operations, rust_types: &RustTypes) {
        }

        glines![
            "match result {",
            "    Ok(output) => {",
            "        let output = try_from_aws(output)?;",
            "        debug!(?output);",
            "        Ok(S3Response::new(output))",
            "    },",
            "    Err(e) => Err(wrap_sdk_error!(e)),",
            "}",
            "match result {"
            "    Ok(output) => {"
            "        let output = try_from_aws(output)?;"
            "        debug!(?output);"
            "        Ok(S3Response::new(output))"
            "    },"
            "    Err(e) => Err(wrap_sdk_error!(e)),"
            "}"
        ];

        g!("}}");
+22 −22
Original line number Diff line number Diff line
@@ -329,18 +329,18 @@ fn unify_operation_types(ops: &Operations, space: &mut RustTypes) {

pub fn codegen(rust_types: &RustTypes) {
    glines![
        "//! Auto generated by `codegen/src/dto.rs`",
        "",
        "#![allow(clippy::empty_structs_with_brackets)]",
        "#![allow(clippy::too_many_lines)]",
        "",
        "use super::*;",
        "",
        "use std::borrow::Cow;",
        "use std::convert::Infallible;",
        "use std::fmt;",
        "use std::str::FromStr;",
        "",
        "//! Auto generated by `codegen/src/dto.rs`"
        ""
        "#![allow(clippy::empty_structs_with_brackets)]"
        "#![allow(clippy::too_many_lines)]"
        ""
        "use super::*;"
        ""
        "use std::borrow::Cow;"
        "use std::convert::Infallible;"
        "use std::fmt;"
        "use std::str::FromStr;"
        ""
    ];

    for rust_type in rust_types.values() {
@@ -443,19 +443,19 @@ fn codegen_str_enum(ty: &rust::StrEnum, _rust_types: &RustTypes) {
        }

        glines![
            "#[must_use]", //
            "pub fn as_str(&self) -> &str {",
            "&self.0",
            "}",
            "",
            "#[must_use]"
            "pub fn as_str(&self) -> &str {"
            "&self.0"
            "}"
            ""
        ];

        glines![
            "#[must_use]",
            "pub fn from_static(s: &'static str) -> Self {",
            "Self(Cow::from(s))",
            "}",
            "",
            "#[must_use]"
            "pub fn from_static(s: &'static str) -> Self {"
            "Self(Cow::from(s))"
            "}"
            ""
        ];
    }
    g!("}}");
+8 −8
Original line number Diff line number Diff line
@@ -123,11 +123,11 @@ pub fn codegen(model: &smithy::Model) {
    let errors = collect_errors(model);

    glines![
        "//! Auto generated by `codegen/src/error.rs`",
        "",
        "use bytestring::ByteString;", //
        "use hyper::StatusCode;",      //
        "",                            //
        "//! Auto generated by `codegen/src/error.rs`"
        ""
        "use bytestring::ByteString;"
        "use hyper::StatusCode;"
        ""
    ];

    g!("#[derive(Debug, Clone, PartialEq, Eq)]");
@@ -191,9 +191,9 @@ pub fn codegen(model: &smithy::Model) {
        g!();

        glines![
            "pub(crate) fn as_static_str(&self) -> Option<&'static str> {",
            "    Self::STATIC_CODE_LIST.get(self.as_enum_tag()).copied()",
            "}",
            "pub(crate) fn as_static_str(&self) -> Option<&'static str> {"
            "    Self::STATIC_CODE_LIST.get(self.as_enum_tag()).copied()"
            "}"
        ];
        g!();
    }
Loading