Unverified Commit b7821e23 authored by Shing Lyu's avatar Shing Lyu Committed by GitHub
Browse files

Make `<servicename>::Client` `Clone + Debug` (#330)



* failed: add Debug trait to Client

* fix: KTLint fixes

* feat: derive Clone for Client

* feat: custom impl Debug for Config

* fix: revert the Debug derives inside Config

* doc: add comment explain why we do custom impl Debug for Config

Co-authored-by: default avatarShing Lyu <shinglyu@amazon.nl>
Co-authored-by: default avatarRussell Cohen <rcoh@amazon.com>
parent 521a201e
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -79,11 +79,13 @@ class FluentClientGenerator(protocolConfig: ProtocolConfig) {
    fun render(writer: RustWriter) {
        writer.rustTemplate(
            """
            ##[derive(std::fmt::Debug)]
            pub(crate) struct Handle {
                client: #{aws_hyper}::Client<#{aws_hyper}::conn::Standard>,
                conf: crate::Config
            }

            ##[derive(Clone, std::fmt::Debug)]
            pub struct Client {
                handle: std::sync::Arc<Handle>
            }
+12 −0
Original line number Diff line number Diff line
@@ -38,6 +38,18 @@ fn types_are_send_sync() {
    assert_send_fut(kms::Client::from_env().list_keys().send());
}

#[test]
fn client_is_debug() {
    let client = kms::Client::from_env();
    assert_ne!(format!("{:?}", client), "");
}

#[test]
fn client_is_clone() {
    let client = kms::Client::from_env();
    let _ = client.clone();
}

/// Parse a semi-real response body and assert that the correct retry status is returned
#[test]
fn errors_are_retryable() {
+13 −0
Original line number Diff line number Diff line
@@ -109,6 +109,19 @@ class ServiceConfigGenerator(private val customizations: List<ConfigCustomizatio
            }
        }

        // Custom implementation for Debug so we don't need to enforce Debug down the chain
        writer.rustBlock("impl std::fmt::Debug for Config") {
            rustTemplate(
                """
            fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
                let mut config = f.debug_struct("Config");
                config.finish()
            }

              """
            )
        }

        writer.rustBlock("impl Config") {
            rustTemplate(
                """