@@ -58,22 +58,18 @@ pub struct S3ConnectionSpec {
5858
5959 /// AWS service API region used by the AWS SDK when using AWS S3 buckets.
6060 ///
61- /// This defaults to `us-east-1`.
61+ /// This defaults to `us-east-1` and can be ignored if not using AWS S3
62+ /// buckets.
6263 ///
63- /// NOTE: This is not the bucket region, and is used by the AWS SDK to make
64- /// endpoints for various AWS service APIs. It is only useful when using AWS
65- /// S3 buckets.
66- ///
67- /// NOTE: This setting is only useful if using AWS S3 buckets. Other S3
68- /// implementations _should not_ require this to be set.
64+ /// NOTE: This is not the bucket region, and is used by the AWS SDK to
65+ /// construct endpoints for various AWS service APIs. It is only useful when
66+ /// using AWS S3 buckets.
6967 ///
7068 /// When using AWS S3 buckets, you can configure optimal AWS service API
7169 /// connections in the following ways:
7270 /// - From **inside** AWS: Use an auto-discovery source (eg: AWS IMDS).
7371 /// - From **outside** AWS, or when IMDS is disabled, explicity set the
7472 /// region name nearest to where the client application is running from.
75- ///
76- /// This defaults to us-east-1, and can be ignored if not using AWS S3.
7773 #[ serde( default ) ]
7874 pub region : AwsRegion ,
7975
@@ -107,6 +103,7 @@ pub enum S3AccessStyle {
107103 VirtualHosted ,
108104}
109105
106+ /// Set a named AWS region, or defer to an auto-discovery mechanism.
110107#[ derive( Clone , Debug , Deserialize , Eq , JsonSchema , PartialEq , Serialize ) ]
111108#[ serde( rename_all = "camelCase" ) ]
112109pub enum AwsRegion {
@@ -118,10 +115,24 @@ pub enum AwsRegion {
118115}
119116
120117impl AwsRegion {
121- /// Get the region.
118+ /// Get the AWS region name.
119+ ///
120+ /// Returns `None` if an auto-discovery source has been selected. Otherwise,
121+ /// it returns the configured region name.
122+ ///
123+ /// Example usage:
124+ ///
125+ /// ```
126+ /// # fn set_property(key: &str, value: String) {
127+ /// # }
122128 ///
123- /// Returns None if an auto-discovery source has been selected.
124- /// Otherwise, returns the configured region name.
129+ /// # fn example(aws_region: AwsRegion) {
130+ /// aws_region.name().and_then(|region_name| {
131+ /// // set some propery if the region is set, or is the default.
132+ /// set_property("aws.region", region_name);
133+ /// });
134+ /// # }
135+ /// ```
125136 pub fn name ( self ) -> Option < String > {
126137 match self {
127138 AwsRegion :: Name ( name) => Some ( name) ,
@@ -136,6 +147,7 @@ impl Default for AwsRegion {
136147 }
137148}
138149
150+ /// AWS region auto-discovery mechanism.
139151#[ derive( Clone , Debug , Deserialize , Eq , JsonSchema , PartialEq , Serialize ) ]
140152#[ serde( rename_all = "PascalCase" ) ]
141153pub enum AwsRegionAutoDiscovery {
0 commit comments