Loading codegen/src/aws_conv.rs +1 −3 Original line number Diff line number Diff line Loading @@ -70,9 +70,7 @@ pub fn codegen(ops: &Operations, rust_types: &RustTypes, g: &mut Codegen) { if field.option_type || field.default_value.is_some() { g.ln(f!("{s3s_field_name}: try_from_aws(x.{aws_field_name})?,")); } else { g.ln(f!( "{s3s_field_name}: unwrap_from_aws(x.{aws_field_name}, \"{s3s_field_name}\")?," )); g.ln(f!("{s3s_field_name}: unwrap_from_aws(x.{aws_field_name}, \"{s3s_field_name}\")?,")); } } } Loading codegen/src/aws_proxy.rs +1 −3 Original line number Diff line number Diff line Loading @@ -24,9 +24,7 @@ pub fn codegen(ops: &Operations, rust_types: &RustTypes, g: &mut Codegen) { let s3s_output = f!("s3s::dto::{}", op.output); let arg = if op.smithy_input == "Unit" { "_" } else { "input" }; g.ln(f!( "async fn {method_name}(&self, {arg}: {s3s_input}) -> S3Result<{s3s_output}> {{" )); g.ln(f!("async fn {method_name}(&self, {arg}: {s3s_input}) -> S3Result<{s3s_output}> {{")); if op.smithy_input == "Unit" { g.ln(f!("let result = self.0.{method_name}().send().await;")); Loading codegen/src/ops.rs +12 −58 Original line number Diff line number Diff line Loading @@ -131,11 +131,7 @@ fn codegen_async_trait(ops: &Operations, g: &mut Codegen) { let method_name = op.name.to_snake_case(); g.ln(f!( "async fn {method_name}(&self, _input: {}) -> S3Result<{}> {{", op.input, op.output )); g.ln(f!("async fn {method_name}(&self, _input: {}) -> S3Result<{}> {{", op.input, op.output)); g.ln(f!("Err(s3_error!(NotImplemented, \"{} is not implemented yet\"))", op.name)); g.ln("}"); Loading Loading @@ -261,12 +257,7 @@ fn codegen_xml_ser(ops: &Operations, rust_types: &RustTypes, g: &mut Codegen) { g.ln(f!("s.timestamp(\"{xml_name}\", val, TimestampFormat::{fmt})?;")); g.ln("}"); } else { g.ln(f!( "s.timestamp(\"{}\", &self.{}, TimestampFormat::{})?;", xml_name, field.name, fmt )); g.ln(f!("s.timestamp(\"{}\", &self.{}, TimestampFormat::{})?;", xml_name, field.name, fmt)); } } else if field.option_type { g.ln(f!("if let Some(ref val) = self.{} {{", field.name)); Loading Loading @@ -438,23 +429,17 @@ fn codegen_xml_de(ops: &Operations, rust_types: &RustTypes, g: &mut Codegen) { g.ln(f!("let ans: {} = d.content()?;", list_ty.member.type_)); g.ln(f!("{field_name}.get_or_insert_with(List::new).push(ans);")); } else { g.ln(f!( "if {field_name}.is_some() {{ return Err(xml::DeError::DuplicateField); }}" )); g.ln(f!("if {field_name}.is_some() {{ return Err(xml::DeError::DuplicateField); }}")); g.ln(f!("{field_name} = Some(d.list_content(\"member\")?);")); } } else if let rust::Type::Timestamp(ts_ty) = field_type { let fmt = ts_ty.format.as_deref().unwrap_or("DateTime"); g.ln(f!( "if {field_name}.is_some() {{ return Err(xml::DeError::DuplicateField); }}" )); g.ln(f!("if {field_name}.is_some() {{ return Err(xml::DeError::DuplicateField); }}")); g.ln(f!("{field_name} = Some(d.timestamp(TimestampFormat::{fmt})?);")); } else { g.ln(f!( "if {field_name}.is_some() {{ return Err(xml::DeError::DuplicateField); }}" )); g.ln(f!("if {field_name}.is_some() {{ return Err(xml::DeError::DuplicateField); }}")); g.ln(f!("{field_name} = Some(d.content()?);")); } Loading Loading @@ -826,12 +811,7 @@ fn codegen_op_http_de(op: &Operation, rust_types: &RustTypes, g: &mut Codegen) { literal, )); } else { g.ln(f!( "let {}: {} = http::parse_query(req, \"{}\")?;", field.name, field.type_, query, )); g.ln(f!("let {}: {} = http::parse_query(req, \"{}\")?;", field.name, field.type_, query,)); } } "header" => { Loading @@ -840,12 +820,7 @@ fn codegen_op_http_de(op: &Operation, rust_types: &RustTypes, g: &mut Codegen) { if let rust::Type::List(_) = field_type { assert!(field.option_type.not()); g.ln(f!( "let {}: {} = http::parse_list_header(req, &{})?;", field.name, field.type_, header )); g.ln(f!("let {}: {} = http::parse_list_header(req, &{})?;", field.name, field.type_, header)); } else if let rust::Type::Timestamp(ts_ty) = field_type { assert!(field.option_type); let fmt = ts_ty.format.as_deref().unwrap_or("HttpDate"); Loading Loading @@ -877,21 +852,12 @@ fn codegen_op_http_de(op: &Operation, rust_types: &RustTypes, g: &mut Codegen) { literal, )); } else { g.ln(f!( "let {}: {} = http::parse_header(req, &{})?;", field.name, field.type_, header )); g.ln(f!("let {}: {} = http::parse_header(req, &{})?;", field.name, field.type_, header)); } } "metadata" => { assert!(field.option_type); g.ln(f!( "let {}: Option<{}> = http::parse_opt_metadata(req)?;", field.name, field.type_ )); g.ln(f!("let {}: Option<{}> = http::parse_opt_metadata(req)?;", field.name, field.type_)); } "payload" => match field.type_.as_str() { "Policy" => { Loading @@ -900,19 +866,11 @@ fn codegen_op_http_de(op: &Operation, rust_types: &RustTypes, g: &mut Codegen) { } "StreamingBlob" => { assert!(field.option_type); g.ln(f!( "let {}: Option<{}> = Some(http::take_stream_body(req));", field.name, field.type_ )); g.ln(f!("let {}: Option<{}> = Some(http::take_stream_body(req));", field.name, field.type_)); } _ => { if field.option_type { g.ln(f!( "let {}: Option<{}> = http::take_opt_xml_body(req)?;", field.name, field.type_ )); g.ln(f!("let {}: Option<{}> = http::take_opt_xml_body(req)?;", field.name, field.type_)); } else { g.ln(f!("let {}: {} = http::take_xml_body(req)?;", field.name, field.type_)); } Loading Loading @@ -1206,11 +1164,7 @@ fn codegen_router(ops: &Operations, rust_types: &RustTypes, g: &mut Codegen) { route.needs_full_body )); } else { g.ln(f!( "Ok((&{} as &'static dyn super::Operation, {}))", route.op.name, route.needs_full_body )); g.ln(f!("Ok((&{} as &'static dyn super::Operation, {}))", route.op.name, route.needs_full_body)); } }; Loading crates/s3s-fs/src/s3.rs +1 −4 Original line number Diff line number Diff line Loading @@ -381,10 +381,7 @@ impl S3 for FileSystem { if key.ends_with('/') { if content_length != 0 { return Err(s3_error!( UnexpectedContent, "Unexpected request body when creating a directory object." )); return Err(s3_error!(UnexpectedContent, "Unexpected request body when creating a directory object.")); } let object_path = self.get_object_path(&bucket, &key)?; try_!(fs::create_dir_all(&object_path).await); Loading crates/s3s/src/dto/range.rs +3 −7 Original line number Diff line number Diff line Loading @@ -47,11 +47,7 @@ impl Range { }; let normal_parser = map_res( tuple(( map_res(digit1, str::parse::<u64>), tag("-"), opt(map_res(digit1, str::parse::<u64>)), )), tuple((map_res(digit1, str::parse::<u64>), tag("-"), opt(map_res(digit1, str::parse::<u64>)))), |ss: (u64, &str, Option<u64>)| { if let (first, Some(last)) = (ss.0, ss.2) { if first > last { Loading @@ -62,8 +58,8 @@ impl Range { }, ); let suffix_parser = map(tuple((tag("-"), map_res(digit1, str::parse::<u64>))), |ss: (&str, u64)| { Range::Suffix { last: ss.1 } let suffix_parser = map(tuple((tag("-"), map_res(digit1, str::parse::<u64>))), |ss: (&str, u64)| Range::Suffix { last: ss.1, }); let mut parser = all_consuming(tuple((tag("bytes="), alt((normal_parser, suffix_parser))))); Loading Loading
codegen/src/aws_conv.rs +1 −3 Original line number Diff line number Diff line Loading @@ -70,9 +70,7 @@ pub fn codegen(ops: &Operations, rust_types: &RustTypes, g: &mut Codegen) { if field.option_type || field.default_value.is_some() { g.ln(f!("{s3s_field_name}: try_from_aws(x.{aws_field_name})?,")); } else { g.ln(f!( "{s3s_field_name}: unwrap_from_aws(x.{aws_field_name}, \"{s3s_field_name}\")?," )); g.ln(f!("{s3s_field_name}: unwrap_from_aws(x.{aws_field_name}, \"{s3s_field_name}\")?,")); } } } Loading
codegen/src/aws_proxy.rs +1 −3 Original line number Diff line number Diff line Loading @@ -24,9 +24,7 @@ pub fn codegen(ops: &Operations, rust_types: &RustTypes, g: &mut Codegen) { let s3s_output = f!("s3s::dto::{}", op.output); let arg = if op.smithy_input == "Unit" { "_" } else { "input" }; g.ln(f!( "async fn {method_name}(&self, {arg}: {s3s_input}) -> S3Result<{s3s_output}> {{" )); g.ln(f!("async fn {method_name}(&self, {arg}: {s3s_input}) -> S3Result<{s3s_output}> {{")); if op.smithy_input == "Unit" { g.ln(f!("let result = self.0.{method_name}().send().await;")); Loading
codegen/src/ops.rs +12 −58 Original line number Diff line number Diff line Loading @@ -131,11 +131,7 @@ fn codegen_async_trait(ops: &Operations, g: &mut Codegen) { let method_name = op.name.to_snake_case(); g.ln(f!( "async fn {method_name}(&self, _input: {}) -> S3Result<{}> {{", op.input, op.output )); g.ln(f!("async fn {method_name}(&self, _input: {}) -> S3Result<{}> {{", op.input, op.output)); g.ln(f!("Err(s3_error!(NotImplemented, \"{} is not implemented yet\"))", op.name)); g.ln("}"); Loading Loading @@ -261,12 +257,7 @@ fn codegen_xml_ser(ops: &Operations, rust_types: &RustTypes, g: &mut Codegen) { g.ln(f!("s.timestamp(\"{xml_name}\", val, TimestampFormat::{fmt})?;")); g.ln("}"); } else { g.ln(f!( "s.timestamp(\"{}\", &self.{}, TimestampFormat::{})?;", xml_name, field.name, fmt )); g.ln(f!("s.timestamp(\"{}\", &self.{}, TimestampFormat::{})?;", xml_name, field.name, fmt)); } } else if field.option_type { g.ln(f!("if let Some(ref val) = self.{} {{", field.name)); Loading Loading @@ -438,23 +429,17 @@ fn codegen_xml_de(ops: &Operations, rust_types: &RustTypes, g: &mut Codegen) { g.ln(f!("let ans: {} = d.content()?;", list_ty.member.type_)); g.ln(f!("{field_name}.get_or_insert_with(List::new).push(ans);")); } else { g.ln(f!( "if {field_name}.is_some() {{ return Err(xml::DeError::DuplicateField); }}" )); g.ln(f!("if {field_name}.is_some() {{ return Err(xml::DeError::DuplicateField); }}")); g.ln(f!("{field_name} = Some(d.list_content(\"member\")?);")); } } else if let rust::Type::Timestamp(ts_ty) = field_type { let fmt = ts_ty.format.as_deref().unwrap_or("DateTime"); g.ln(f!( "if {field_name}.is_some() {{ return Err(xml::DeError::DuplicateField); }}" )); g.ln(f!("if {field_name}.is_some() {{ return Err(xml::DeError::DuplicateField); }}")); g.ln(f!("{field_name} = Some(d.timestamp(TimestampFormat::{fmt})?);")); } else { g.ln(f!( "if {field_name}.is_some() {{ return Err(xml::DeError::DuplicateField); }}" )); g.ln(f!("if {field_name}.is_some() {{ return Err(xml::DeError::DuplicateField); }}")); g.ln(f!("{field_name} = Some(d.content()?);")); } Loading Loading @@ -826,12 +811,7 @@ fn codegen_op_http_de(op: &Operation, rust_types: &RustTypes, g: &mut Codegen) { literal, )); } else { g.ln(f!( "let {}: {} = http::parse_query(req, \"{}\")?;", field.name, field.type_, query, )); g.ln(f!("let {}: {} = http::parse_query(req, \"{}\")?;", field.name, field.type_, query,)); } } "header" => { Loading @@ -840,12 +820,7 @@ fn codegen_op_http_de(op: &Operation, rust_types: &RustTypes, g: &mut Codegen) { if let rust::Type::List(_) = field_type { assert!(field.option_type.not()); g.ln(f!( "let {}: {} = http::parse_list_header(req, &{})?;", field.name, field.type_, header )); g.ln(f!("let {}: {} = http::parse_list_header(req, &{})?;", field.name, field.type_, header)); } else if let rust::Type::Timestamp(ts_ty) = field_type { assert!(field.option_type); let fmt = ts_ty.format.as_deref().unwrap_or("HttpDate"); Loading Loading @@ -877,21 +852,12 @@ fn codegen_op_http_de(op: &Operation, rust_types: &RustTypes, g: &mut Codegen) { literal, )); } else { g.ln(f!( "let {}: {} = http::parse_header(req, &{})?;", field.name, field.type_, header )); g.ln(f!("let {}: {} = http::parse_header(req, &{})?;", field.name, field.type_, header)); } } "metadata" => { assert!(field.option_type); g.ln(f!( "let {}: Option<{}> = http::parse_opt_metadata(req)?;", field.name, field.type_ )); g.ln(f!("let {}: Option<{}> = http::parse_opt_metadata(req)?;", field.name, field.type_)); } "payload" => match field.type_.as_str() { "Policy" => { Loading @@ -900,19 +866,11 @@ fn codegen_op_http_de(op: &Operation, rust_types: &RustTypes, g: &mut Codegen) { } "StreamingBlob" => { assert!(field.option_type); g.ln(f!( "let {}: Option<{}> = Some(http::take_stream_body(req));", field.name, field.type_ )); g.ln(f!("let {}: Option<{}> = Some(http::take_stream_body(req));", field.name, field.type_)); } _ => { if field.option_type { g.ln(f!( "let {}: Option<{}> = http::take_opt_xml_body(req)?;", field.name, field.type_ )); g.ln(f!("let {}: Option<{}> = http::take_opt_xml_body(req)?;", field.name, field.type_)); } else { g.ln(f!("let {}: {} = http::take_xml_body(req)?;", field.name, field.type_)); } Loading Loading @@ -1206,11 +1164,7 @@ fn codegen_router(ops: &Operations, rust_types: &RustTypes, g: &mut Codegen) { route.needs_full_body )); } else { g.ln(f!( "Ok((&{} as &'static dyn super::Operation, {}))", route.op.name, route.needs_full_body )); g.ln(f!("Ok((&{} as &'static dyn super::Operation, {}))", route.op.name, route.needs_full_body)); } }; Loading
crates/s3s-fs/src/s3.rs +1 −4 Original line number Diff line number Diff line Loading @@ -381,10 +381,7 @@ impl S3 for FileSystem { if key.ends_with('/') { if content_length != 0 { return Err(s3_error!( UnexpectedContent, "Unexpected request body when creating a directory object." )); return Err(s3_error!(UnexpectedContent, "Unexpected request body when creating a directory object.")); } let object_path = self.get_object_path(&bucket, &key)?; try_!(fs::create_dir_all(&object_path).await); Loading
crates/s3s/src/dto/range.rs +3 −7 Original line number Diff line number Diff line Loading @@ -47,11 +47,7 @@ impl Range { }; let normal_parser = map_res( tuple(( map_res(digit1, str::parse::<u64>), tag("-"), opt(map_res(digit1, str::parse::<u64>)), )), tuple((map_res(digit1, str::parse::<u64>), tag("-"), opt(map_res(digit1, str::parse::<u64>)))), |ss: (u64, &str, Option<u64>)| { if let (first, Some(last)) = (ss.0, ss.2) { if first > last { Loading @@ -62,8 +58,8 @@ impl Range { }, ); let suffix_parser = map(tuple((tag("-"), map_res(digit1, str::parse::<u64>))), |ss: (&str, u64)| { Range::Suffix { last: ss.1 } let suffix_parser = map(tuple((tag("-"), map_res(digit1, str::parse::<u64>))), |ss: (&str, u64)| Range::Suffix { last: ss.1, }); let mut parser = all_consuming(tuple((tag("bytes="), alt((normal_parser, suffix_parser))))); Loading