awsdocs / aws-doc-sdk-examples

Welcome to the AWS Code Examples Repository. This repo contains code examples used in the AWS documentation, AWS SDK Developer Guides, and more. For more information, see the Readme.md file below.
Apache License 2.0
9.62k stars 5.64k forks source link

Rust: Examples for the interceptor documentation do not compile #7052

Closed DavidSouther closed 1 week ago

DavidSouther commented 1 week ago

See https://github.com/awslabs/aws-sdk-rust/issues/1212


MathieuDuponchelle:

I am trying to make use of the interceptor API.

The example in the documentation @ https://docs.rs/aws-sdk-transcribestreaming/latest/aws_sdk_transcribestreaming/config/struct.Builder.html#method.interceptor does not compile.

Once I do get it to compile, I'm also only getting my read_before_deserialization() implementation called once:

  #[derive(Debug)] 
  struct MyInterceptor {                                                                                                       
  }       

  impl Intercept for MyInterceptor {                                                                                           
      fn name(&self) -> &'static str {                                                                                         
          "transcriber-stream"                                                                                                 
      }                                                                                                                        

      fn read_before_deserialization(&self,                                                                                    
          _context: &BeforeDeserializationInterceptorContextRef<'_>,                                                           
          _runtime_components: &RuntimeComponents, _cfg: &mut ConfigBag,) -> Result<(), Box<dyn core::error::Error + Send + Sync>> {      
          eprintln!("Here");

          Ok(())
      }
  } 

// ...

              let my_interceptor = MyInterceptor {};
              let builder = aws_transcribe::config::Builder::from(aws_config)
                  .interceptor(my_interceptor);
              aws_transcribe::Client::from_conf(builder.build())

Links https://docs.rs/aws-sdk-transcribestreaming/latest/aws_sdk_transcribestreaming/config/struct.Builder.html#method.interceptor

DavidSouther commented 1 week ago

Looks like this is the docblock example, and comes from https://github.com/smithy-lang/smithy-rs/blob/fd10a1640669e34e2ae8be9d137336dfa145051b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/InterceptorConfigCustomization.kt#L66

MathieuDuponchelle commented 1 week ago

I don't understand why this was opened then closed, the code in the transcribe streaming documentation still does not compile :)

DavidSouther commented 1 week ago

That example comes from the SDK generator, and is tracked in the smithy-rs project. It was opened because we thought it was here, then closed as "issue in the wrong repo". The original issue you opened is still open and awaiting a fix in the generator!

MathieuDuponchelle commented 1 week ago

Ah I see, my bad :)