awslabs / aws-sdk-rust

AWS SDK for the Rust Programming Language
https://awslabs.github.io/aws-sdk-rust/
Apache License 2.0
3.04k stars 247 forks source link

Examples for the interceptor documentation do not compile #1212

Open MathieuDuponchelle opened 3 weeks ago

MathieuDuponchelle commented 3 weeks ago

Describe the issue

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

Velfi commented 2 weeks ago

Thanks for reporting this. I'll let the example writer know.

DavidSouther commented 2 weeks ago

~https://github.com/awsdocs/aws-doc-sdk-examples/issues/7052~ This is a 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