Loading codegen/src/aws.rs→codegen/src/aws_conv.rs +3 −1 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ pub fn codegen(ops: &Operations, rust_types: &RustTypes, g: &mut Codegen) { rust::Type::StructEnum(_) => {} } let s3s_path = f!("crate::dto::{name}"); let s3s_path = f!("s3s::dto::{name}"); let aws_name = aws_ty_name(name); g.ln(f!("impl AwsConversion for {s3s_path} {{")); Loading Loading @@ -138,6 +138,7 @@ pub fn codegen(ops: &Operations, rust_types: &RustTypes, g: &mut Codegen) { for variant in &ty.variants { g.ln(f!("Self::{0} => {aws_name}::{0},", variant.name)); } g.ln("_ => unreachable!(),"); g.ln("})"); } rust::Type::StructEnum(ty) => { Loading @@ -145,6 +146,7 @@ pub fn codegen(ops: &Operations, rust_types: &RustTypes, g: &mut Codegen) { for variant in &ty.variants { g.ln(f!("Self::{0}(v) => {aws_name}::{0}(try_into_aws(v)?),", variant.name)); } g.ln("_ => unreachable!(),"); g.ln("})"); } _ => panic!(), Loading codegen/src/main.rs +3 −3 Original line number Diff line number Diff line Loading @@ -15,7 +15,7 @@ mod error; mod headers; mod ops; mod aws; mod aws_conv; use crate::gen::Codegen; Loading Loading @@ -65,8 +65,8 @@ fn main() { } { let path = "crates/s3s/src/aws/generated.rs"; let path = "crates/s3s-aws/src/conv/generated.rs"; let mut gen = Codegen::create_file(path).unwrap(); aws::codegen(&ops, &rust_types, &mut gen); aws_conv::codegen(&ops, &rust_types, &mut gen); } } crates/s3s-aws/Cargo.toml +1 −0 Original line number Diff line number Diff line Loading @@ -13,6 +13,7 @@ categories = ["web-programming", "web-programming::http-server"] aws-sdk-s3 = "0.23.0" aws-smithy-http = "0.53.1" aws-smithy-types = "0.53.1" aws-smithy-types-convert = { version = "0.53.1", features = ["convert-time"] } futures = { version = "0.3.25", default-features = false, features = ["std"] } hyper = "0.14.23" s3s = { version = "0.2.0-dev", path = "../s3s" } crates/s3s/src/aws/generated.rs→crates/s3s-aws/src/conv/generated.rs +404 −343 File changed and moved.Preview size limit exceeded, changes collapsed. Show changes crates/s3s/src/aws/mod.rs→crates/s3s-aws/src/conv/mod.rs +11 −23 Original line number Diff line number Diff line mod generated; use crate::error::{S3Error, S3Result}; use s3s::s3_error; use s3s::{S3Error, S3Result}; use std::collections::HashMap; Loading Loading @@ -73,7 +74,7 @@ impl<T: AwsConversion> AwsConversion for Vec<T> { } } impl AwsConversion for crate::dto::Timestamp { impl AwsConversion for s3s::dto::Timestamp { type Target = aws_sdk_s3::types::DateTime; fn try_from_aws(x: Self::Target) -> S3Result<Self> { Loading @@ -87,7 +88,7 @@ impl AwsConversion for crate::dto::Timestamp { } } impl AwsConversion for crate::dto::ContentType { impl AwsConversion for s3s::dto::ContentType { type Target = String; fn try_from_aws(x: Self::Target) -> S3Result<Self> { Loading @@ -99,7 +100,7 @@ impl AwsConversion for crate::dto::ContentType { } } impl AwsConversion for crate::dto::CopySource { impl AwsConversion for s3s::dto::CopySource { type Target = String; fn try_from_aws(x: Self::Target) -> S3Result<Self> { Loading @@ -111,7 +112,7 @@ impl AwsConversion for crate::dto::CopySource { } } impl AwsConversion for crate::dto::Range { impl AwsConversion for s3s::dto::Range { type Target = String; fn try_from_aws(x: Self::Target) -> S3Result<Self> { Loading @@ -123,7 +124,7 @@ impl AwsConversion for crate::dto::Range { } } impl AwsConversion for crate::dto::Event { impl AwsConversion for s3s::dto::Event { type Target = aws_sdk_s3::model::Event; fn try_from_aws(x: Self::Target) -> S3Result<Self> { Loading @@ -135,11 +136,11 @@ impl AwsConversion for crate::dto::Event { } } fn stream_from_aws(x: aws_sdk_s3::types::ByteStream) -> Option<crate::dto::StreamingBlob> { Some(crate::dto::StreamingBlob::wrap(x)) fn stream_from_aws(x: aws_sdk_s3::types::ByteStream) -> Option<s3s::dto::StreamingBlob> { Some(s3s::dto::StreamingBlob::wrap(x)) } impl AwsConversion for crate::dto::StreamingBlob { impl AwsConversion for s3s::dto::StreamingBlob { type Target = aws_sdk_s3::types::ByteStream; fn try_from_aws(x: Self::Target) -> S3Result<Self> { Loading @@ -151,7 +152,7 @@ impl AwsConversion for crate::dto::StreamingBlob { } } impl AwsConversion for crate::dto::Body { impl AwsConversion for s3s::dto::Body { type Target = aws_sdk_s3::types::Blob; fn try_from_aws(x: Self::Target) -> S3Result<Self> { Loading @@ -162,16 +163,3 @@ impl AwsConversion for crate::dto::Body { Ok(Self::Target::new(x)) } } #[cfg(test)] mod tests { use super::*; #[test] fn mime() { let x: crate::dto::ContentType = mime::TEXT_XML; let y = try_into_aws(x.clone()).unwrap(); let z: crate::dto::ContentType = try_from_aws(y).unwrap(); assert_eq!(x, z); } } Loading
codegen/src/aws.rs→codegen/src/aws_conv.rs +3 −1 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ pub fn codegen(ops: &Operations, rust_types: &RustTypes, g: &mut Codegen) { rust::Type::StructEnum(_) => {} } let s3s_path = f!("crate::dto::{name}"); let s3s_path = f!("s3s::dto::{name}"); let aws_name = aws_ty_name(name); g.ln(f!("impl AwsConversion for {s3s_path} {{")); Loading Loading @@ -138,6 +138,7 @@ pub fn codegen(ops: &Operations, rust_types: &RustTypes, g: &mut Codegen) { for variant in &ty.variants { g.ln(f!("Self::{0} => {aws_name}::{0},", variant.name)); } g.ln("_ => unreachable!(),"); g.ln("})"); } rust::Type::StructEnum(ty) => { Loading @@ -145,6 +146,7 @@ pub fn codegen(ops: &Operations, rust_types: &RustTypes, g: &mut Codegen) { for variant in &ty.variants { g.ln(f!("Self::{0}(v) => {aws_name}::{0}(try_into_aws(v)?),", variant.name)); } g.ln("_ => unreachable!(),"); g.ln("})"); } _ => panic!(), Loading
codegen/src/main.rs +3 −3 Original line number Diff line number Diff line Loading @@ -15,7 +15,7 @@ mod error; mod headers; mod ops; mod aws; mod aws_conv; use crate::gen::Codegen; Loading Loading @@ -65,8 +65,8 @@ fn main() { } { let path = "crates/s3s/src/aws/generated.rs"; let path = "crates/s3s-aws/src/conv/generated.rs"; let mut gen = Codegen::create_file(path).unwrap(); aws::codegen(&ops, &rust_types, &mut gen); aws_conv::codegen(&ops, &rust_types, &mut gen); } }
crates/s3s-aws/Cargo.toml +1 −0 Original line number Diff line number Diff line Loading @@ -13,6 +13,7 @@ categories = ["web-programming", "web-programming::http-server"] aws-sdk-s3 = "0.23.0" aws-smithy-http = "0.53.1" aws-smithy-types = "0.53.1" aws-smithy-types-convert = { version = "0.53.1", features = ["convert-time"] } futures = { version = "0.3.25", default-features = false, features = ["std"] } hyper = "0.14.23" s3s = { version = "0.2.0-dev", path = "../s3s" }
crates/s3s/src/aws/generated.rs→crates/s3s-aws/src/conv/generated.rs +404 −343 File changed and moved.Preview size limit exceeded, changes collapsed. Show changes
crates/s3s/src/aws/mod.rs→crates/s3s-aws/src/conv/mod.rs +11 −23 Original line number Diff line number Diff line mod generated; use crate::error::{S3Error, S3Result}; use s3s::s3_error; use s3s::{S3Error, S3Result}; use std::collections::HashMap; Loading Loading @@ -73,7 +74,7 @@ impl<T: AwsConversion> AwsConversion for Vec<T> { } } impl AwsConversion for crate::dto::Timestamp { impl AwsConversion for s3s::dto::Timestamp { type Target = aws_sdk_s3::types::DateTime; fn try_from_aws(x: Self::Target) -> S3Result<Self> { Loading @@ -87,7 +88,7 @@ impl AwsConversion for crate::dto::Timestamp { } } impl AwsConversion for crate::dto::ContentType { impl AwsConversion for s3s::dto::ContentType { type Target = String; fn try_from_aws(x: Self::Target) -> S3Result<Self> { Loading @@ -99,7 +100,7 @@ impl AwsConversion for crate::dto::ContentType { } } impl AwsConversion for crate::dto::CopySource { impl AwsConversion for s3s::dto::CopySource { type Target = String; fn try_from_aws(x: Self::Target) -> S3Result<Self> { Loading @@ -111,7 +112,7 @@ impl AwsConversion for crate::dto::CopySource { } } impl AwsConversion for crate::dto::Range { impl AwsConversion for s3s::dto::Range { type Target = String; fn try_from_aws(x: Self::Target) -> S3Result<Self> { Loading @@ -123,7 +124,7 @@ impl AwsConversion for crate::dto::Range { } } impl AwsConversion for crate::dto::Event { impl AwsConversion for s3s::dto::Event { type Target = aws_sdk_s3::model::Event; fn try_from_aws(x: Self::Target) -> S3Result<Self> { Loading @@ -135,11 +136,11 @@ impl AwsConversion for crate::dto::Event { } } fn stream_from_aws(x: aws_sdk_s3::types::ByteStream) -> Option<crate::dto::StreamingBlob> { Some(crate::dto::StreamingBlob::wrap(x)) fn stream_from_aws(x: aws_sdk_s3::types::ByteStream) -> Option<s3s::dto::StreamingBlob> { Some(s3s::dto::StreamingBlob::wrap(x)) } impl AwsConversion for crate::dto::StreamingBlob { impl AwsConversion for s3s::dto::StreamingBlob { type Target = aws_sdk_s3::types::ByteStream; fn try_from_aws(x: Self::Target) -> S3Result<Self> { Loading @@ -151,7 +152,7 @@ impl AwsConversion for crate::dto::StreamingBlob { } } impl AwsConversion for crate::dto::Body { impl AwsConversion for s3s::dto::Body { type Target = aws_sdk_s3::types::Blob; fn try_from_aws(x: Self::Target) -> S3Result<Self> { Loading @@ -162,16 +163,3 @@ impl AwsConversion for crate::dto::Body { Ok(Self::Target::new(x)) } } #[cfg(test)] mod tests { use super::*; #[test] fn mime() { let x: crate::dto::ContentType = mime::TEXT_XML; let y = try_into_aws(x.clone()).unwrap(); let z: crate::dto::ContentType = try_from_aws(y).unwrap(); assert_eq!(x, z); } }