Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions codegen/src/v1/dto.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use super::o;
use super::ops::{Operations, SKIPPED_OPS, is_op_input};
use super::order;
use super::rust::codegen_doc;
use super::smithy::SmithyTraitsExt;
use super::{rust, smithy};
Expand Down Expand Up @@ -151,7 +152,25 @@ pub fn collect_rust_types(model: &smithy::Model, ops: &Operations) -> RustTypes
}
smithy::Shape::Structure(shape) => {
let mut fields = Vec::new();
for (field_name, field) in &shape.members {
let member_list: Vec<(&str, &smithy::StructureMember)> =
if let Some(order) = order::struct_member_order(&rs_shape_name) {
let order_set: BTreeSet<&str> = order.iter().copied().collect();
let mut list = Vec::new();
for &name in order {
if let Some(field) = shape.members.get(name) {
list.push((name, field));
}
}
for (name, field) in &shape.members {
if !order_set.contains(name.as_str()) {
list.push((name.as_str(), field));
}
}
list
} else {
shape.members.iter().map(|(k, v)| (k.as_str(), v)).collect()
};
for (field_name, field) in member_list {
let rs_field_name = if field_name == "Type" {
"type_".into()
} else {
Expand Down Expand Up @@ -212,7 +231,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.clone(),
camel_name: field_name.to_owned(),

option_type,
default_value,
Expand Down
1 change: 1 addition & 0 deletions codegen/src/v1/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ mod error;
mod headers;
mod minio;
mod ops;
mod order;
mod s3_trait;
mod sts;
mod xml;
Expand Down
37 changes: 37 additions & 0 deletions codegen/src/v1/order.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
pub fn struct_member_order(shape_name: &str) -> Option<&'static [&'static str]> {
match shape_name {
"ListObjectsOutput" => Some(LIST_OBJECTS_OUTPUT_ORDER),
"ListObjectsV2Output" => Some(LIST_OBJECTS_V2_OUTPUT_ORDER),
_ => None,
}
}

const LIST_OBJECTS_OUTPUT_ORDER: &[&str] = &[
"Name",
"Prefix",
"Marker",
"MaxKeys",
"IsTruncated",
"Contents",
"CommonPrefixes",
"Delimiter",
"NextMarker",
"EncodingType",
"RequestCharged",
];

const LIST_OBJECTS_V2_OUTPUT_ORDER: &[&str] = &[
"Name",
"Prefix",
"MaxKeys",
"KeyCount",
"ContinuationToken",
"IsTruncated",
"NextContinuationToken",
"Contents",
"CommonPrefixes",
"Delimiter",
"EncodingType",
"StartAfter",
"RequestCharged",
];
64 changes: 32 additions & 32 deletions crates/s3s-aws/src/conv/generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5051,32 +5051,32 @@ impl AwsConversion for s3s::dto::ListObjectsOutput {

fn try_from_aws(x: Self::Target) -> S3Result<Self> {
Ok(Self {
common_prefixes: try_from_aws(x.common_prefixes)?,
contents: try_from_aws(x.contents)?,
delimiter: try_from_aws(x.delimiter)?,
encoding_type: try_from_aws(x.encoding_type)?,
is_truncated: try_from_aws(x.is_truncated)?,
name: try_from_aws(x.name)?,
prefix: try_from_aws(x.prefix)?,
marker: try_from_aws(x.marker)?,
max_keys: try_from_aws(x.max_keys)?,
name: try_from_aws(x.name)?,
is_truncated: try_from_aws(x.is_truncated)?,
contents: try_from_aws(x.contents)?,
common_prefixes: try_from_aws(x.common_prefixes)?,
delimiter: try_from_aws(x.delimiter)?,
next_marker: try_from_aws(x.next_marker)?,
prefix: try_from_aws(x.prefix)?,
encoding_type: try_from_aws(x.encoding_type)?,
request_charged: try_from_aws(x.request_charged)?,
})
}

fn try_into_aws(x: Self) -> S3Result<Self::Target> {
let mut y = Self::Target::builder();
y = y.set_common_prefixes(try_into_aws(x.common_prefixes)?);
y = y.set_contents(try_into_aws(x.contents)?);
y = y.set_delimiter(try_into_aws(x.delimiter)?);
y = y.set_encoding_type(try_into_aws(x.encoding_type)?);
y = y.set_is_truncated(try_into_aws(x.is_truncated)?);
y = y.set_name(try_into_aws(x.name)?);
y = y.set_prefix(try_into_aws(x.prefix)?);
y = y.set_marker(try_into_aws(x.marker)?);
y = y.set_max_keys(try_into_aws(x.max_keys)?);
y = y.set_name(try_into_aws(x.name)?);
y = y.set_is_truncated(try_into_aws(x.is_truncated)?);
y = y.set_contents(try_into_aws(x.contents)?);
y = y.set_common_prefixes(try_into_aws(x.common_prefixes)?);
y = y.set_delimiter(try_into_aws(x.delimiter)?);
y = y.set_next_marker(try_into_aws(x.next_marker)?);
y = y.set_prefix(try_into_aws(x.prefix)?);
y = y.set_encoding_type(try_into_aws(x.encoding_type)?);
y = y.set_request_charged(try_into_aws(x.request_charged)?);
Ok(y.build())
}
Expand Down Expand Up @@ -5125,37 +5125,37 @@ impl AwsConversion for s3s::dto::ListObjectsV2Output {

fn try_from_aws(x: Self::Target) -> S3Result<Self> {
Ok(Self {
common_prefixes: try_from_aws(x.common_prefixes)?,
contents: try_from_aws(x.contents)?,
name: try_from_aws(x.name)?,
prefix: try_from_aws(x.prefix)?,
max_keys: try_from_aws(x.max_keys)?,
key_count: try_from_aws(x.key_count)?,
continuation_token: try_from_aws(x.continuation_token)?,
delimiter: try_from_aws(x.delimiter)?,
encoding_type: try_from_aws(x.encoding_type)?,
is_truncated: try_from_aws(x.is_truncated)?,
key_count: try_from_aws(x.key_count)?,
max_keys: try_from_aws(x.max_keys)?,
name: try_from_aws(x.name)?,
next_continuation_token: try_from_aws(x.next_continuation_token)?,
prefix: try_from_aws(x.prefix)?,
request_charged: try_from_aws(x.request_charged)?,
contents: try_from_aws(x.contents)?,
common_prefixes: try_from_aws(x.common_prefixes)?,
delimiter: try_from_aws(x.delimiter)?,
encoding_type: try_from_aws(x.encoding_type)?,
start_after: try_from_aws(x.start_after)?,
request_charged: try_from_aws(x.request_charged)?,
})
}

fn try_into_aws(x: Self) -> S3Result<Self::Target> {
let mut y = Self::Target::builder();
y = y.set_common_prefixes(try_into_aws(x.common_prefixes)?);
y = y.set_contents(try_into_aws(x.contents)?);
y = y.set_name(try_into_aws(x.name)?);
y = y.set_prefix(try_into_aws(x.prefix)?);
y = y.set_max_keys(try_into_aws(x.max_keys)?);
y = y.set_key_count(try_into_aws(x.key_count)?);
y = y.set_continuation_token(try_into_aws(x.continuation_token)?);
y = y.set_delimiter(try_into_aws(x.delimiter)?);
y = y.set_encoding_type(try_into_aws(x.encoding_type)?);
y = y.set_is_truncated(try_into_aws(x.is_truncated)?);
y = y.set_key_count(try_into_aws(x.key_count)?);
y = y.set_max_keys(try_into_aws(x.max_keys)?);
y = y.set_name(try_into_aws(x.name)?);
y = y.set_next_continuation_token(try_into_aws(x.next_continuation_token)?);
y = y.set_prefix(try_into_aws(x.prefix)?);
y = y.set_request_charged(try_into_aws(x.request_charged)?);
y = y.set_contents(try_into_aws(x.contents)?);
y = y.set_common_prefixes(try_into_aws(x.common_prefixes)?);
y = y.set_delimiter(try_into_aws(x.delimiter)?);
y = y.set_encoding_type(try_into_aws(x.encoding_type)?);
y = y.set_start_after(try_into_aws(x.start_after)?);
y = y.set_request_charged(try_into_aws(x.request_charged)?);
Ok(y.build())
}
}
Expand Down
64 changes: 32 additions & 32 deletions crates/s3s-aws/src/conv/generated_minio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5055,32 +5055,32 @@ impl AwsConversion for s3s::dto::ListObjectsOutput {

fn try_from_aws(x: Self::Target) -> S3Result<Self> {
Ok(Self {
common_prefixes: try_from_aws(x.common_prefixes)?,
contents: try_from_aws(x.contents)?,
delimiter: try_from_aws(x.delimiter)?,
encoding_type: try_from_aws(x.encoding_type)?,
is_truncated: try_from_aws(x.is_truncated)?,
name: try_from_aws(x.name)?,
prefix: try_from_aws(x.prefix)?,
marker: try_from_aws(x.marker)?,
max_keys: try_from_aws(x.max_keys)?,
name: try_from_aws(x.name)?,
is_truncated: try_from_aws(x.is_truncated)?,
contents: try_from_aws(x.contents)?,
common_prefixes: try_from_aws(x.common_prefixes)?,
delimiter: try_from_aws(x.delimiter)?,
next_marker: try_from_aws(x.next_marker)?,
prefix: try_from_aws(x.prefix)?,
encoding_type: try_from_aws(x.encoding_type)?,
request_charged: try_from_aws(x.request_charged)?,
})
}

fn try_into_aws(x: Self) -> S3Result<Self::Target> {
let mut y = Self::Target::builder();
y = y.set_common_prefixes(try_into_aws(x.common_prefixes)?);
y = y.set_contents(try_into_aws(x.contents)?);
y = y.set_delimiter(try_into_aws(x.delimiter)?);
y = y.set_encoding_type(try_into_aws(x.encoding_type)?);
y = y.set_is_truncated(try_into_aws(x.is_truncated)?);
y = y.set_name(try_into_aws(x.name)?);
y = y.set_prefix(try_into_aws(x.prefix)?);
y = y.set_marker(try_into_aws(x.marker)?);
y = y.set_max_keys(try_into_aws(x.max_keys)?);
y = y.set_name(try_into_aws(x.name)?);
y = y.set_is_truncated(try_into_aws(x.is_truncated)?);
y = y.set_contents(try_into_aws(x.contents)?);
y = y.set_common_prefixes(try_into_aws(x.common_prefixes)?);
y = y.set_delimiter(try_into_aws(x.delimiter)?);
y = y.set_next_marker(try_into_aws(x.next_marker)?);
y = y.set_prefix(try_into_aws(x.prefix)?);
y = y.set_encoding_type(try_into_aws(x.encoding_type)?);
y = y.set_request_charged(try_into_aws(x.request_charged)?);
Ok(y.build())
}
Expand Down Expand Up @@ -5129,37 +5129,37 @@ impl AwsConversion for s3s::dto::ListObjectsV2Output {

fn try_from_aws(x: Self::Target) -> S3Result<Self> {
Ok(Self {
common_prefixes: try_from_aws(x.common_prefixes)?,
contents: try_from_aws(x.contents)?,
name: try_from_aws(x.name)?,
prefix: try_from_aws(x.prefix)?,
max_keys: try_from_aws(x.max_keys)?,
key_count: try_from_aws(x.key_count)?,
continuation_token: try_from_aws(x.continuation_token)?,
delimiter: try_from_aws(x.delimiter)?,
encoding_type: try_from_aws(x.encoding_type)?,
is_truncated: try_from_aws(x.is_truncated)?,
key_count: try_from_aws(x.key_count)?,
max_keys: try_from_aws(x.max_keys)?,
name: try_from_aws(x.name)?,
next_continuation_token: try_from_aws(x.next_continuation_token)?,
prefix: try_from_aws(x.prefix)?,
request_charged: try_from_aws(x.request_charged)?,
contents: try_from_aws(x.contents)?,
common_prefixes: try_from_aws(x.common_prefixes)?,
delimiter: try_from_aws(x.delimiter)?,
encoding_type: try_from_aws(x.encoding_type)?,
start_after: try_from_aws(x.start_after)?,
request_charged: try_from_aws(x.request_charged)?,
})
}

fn try_into_aws(x: Self) -> S3Result<Self::Target> {
let mut y = Self::Target::builder();
y = y.set_common_prefixes(try_into_aws(x.common_prefixes)?);
y = y.set_contents(try_into_aws(x.contents)?);
y = y.set_name(try_into_aws(x.name)?);
y = y.set_prefix(try_into_aws(x.prefix)?);
y = y.set_max_keys(try_into_aws(x.max_keys)?);
y = y.set_key_count(try_into_aws(x.key_count)?);
y = y.set_continuation_token(try_into_aws(x.continuation_token)?);
y = y.set_delimiter(try_into_aws(x.delimiter)?);
y = y.set_encoding_type(try_into_aws(x.encoding_type)?);
y = y.set_is_truncated(try_into_aws(x.is_truncated)?);
y = y.set_key_count(try_into_aws(x.key_count)?);
y = y.set_max_keys(try_into_aws(x.max_keys)?);
y = y.set_name(try_into_aws(x.name)?);
y = y.set_next_continuation_token(try_into_aws(x.next_continuation_token)?);
y = y.set_prefix(try_into_aws(x.prefix)?);
y = y.set_request_charged(try_into_aws(x.request_charged)?);
y = y.set_contents(try_into_aws(x.contents)?);
y = y.set_common_prefixes(try_into_aws(x.common_prefixes)?);
y = y.set_delimiter(try_into_aws(x.delimiter)?);
y = y.set_encoding_type(try_into_aws(x.encoding_type)?);
y = y.set_start_after(try_into_aws(x.start_after)?);
y = y.set_request_charged(try_into_aws(x.request_charged)?);
Ok(y.build())
}
}
Expand Down
Loading