aws-sdk-bedrockagentcore 1.13.0

AWS SDK for Amazon Bedrock AgentCore Data Plane Fronting Layer
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
#[non_exhaustive]
#[derive(Debug)]
pub struct CodeInterpreterStreamOutputUnmarshaller;

impl CodeInterpreterStreamOutputUnmarshaller {
    pub fn new() -> Self {
        CodeInterpreterStreamOutputUnmarshaller
    }
}
impl ::aws_smithy_eventstream::frame::UnmarshallMessage for CodeInterpreterStreamOutputUnmarshaller {
    type Output = crate::types::CodeInterpreterStreamOutput;
    type Error = crate::types::error::CodeInterpreterStreamOutputError;
    fn unmarshall(
        &self,
        message: &::aws_smithy_types::event_stream::Message,
    ) -> std::result::Result<::aws_smithy_eventstream::frame::UnmarshalledMessage<Self::Output, Self::Error>, ::aws_smithy_eventstream::error::Error>
    {
        let response_headers = ::aws_smithy_eventstream::smithy::parse_response_headers(message)?;
        match response_headers.message_type.as_str() {
            "event" => match response_headers.smithy_type.as_str() {
                "result" => {
                    let parsed = crate::protocol_serde::shape_code_interpreter_result::de_code_interpreter_result_payload(&message.payload()[..])
                        .map_err(|err| ::aws_smithy_eventstream::error::Error::unmarshalling(format!("failed to unmarshall Result: {}", err)))?;
                    Ok(::aws_smithy_eventstream::frame::UnmarshalledMessage::Event(
                        crate::types::CodeInterpreterStreamOutput::Result(parsed),
                    ))
                }
                _unknown_variant => Ok(::aws_smithy_eventstream::frame::UnmarshalledMessage::Event(
                    crate::types::CodeInterpreterStreamOutput::Unknown,
                )),
            },
            "exception" => {
                let generic = match crate::protocol_serde::parse_event_stream_error_metadata(message.payload()) {
                    Ok(builder) => builder.build(),
                    Err(err) => {
                        return Ok(::aws_smithy_eventstream::frame::UnmarshalledMessage::Error(
                            crate::types::error::CodeInterpreterStreamOutputError::unhandled(err),
                        ))
                    }
                };
                match response_headers.smithy_type.as_str() {
                    "accessDeniedException" => {
                        let mut builder = crate::types::error::builders::AccessDeniedExceptionBuilder::default();
                        builder = crate::protocol_serde::shape_access_denied_exception::de_access_denied_exception_json_err(
                            &message.payload()[..],
                            builder,
                        )
                        .map_err(|err| {
                            ::aws_smithy_eventstream::error::Error::unmarshalling(format!("failed to unmarshall accessDeniedException: {}", err))
                        })?;
                        builder.set_meta(Some(generic));
                        return Ok(::aws_smithy_eventstream::frame::UnmarshalledMessage::Error(
                            crate::types::error::CodeInterpreterStreamOutputError::AccessDeniedException(builder.build()),
                        ));
                    }
                    "conflictException" => {
                        let mut builder = crate::types::error::builders::ConflictExceptionBuilder::default();
                        builder = crate::protocol_serde::shape_conflict_exception::de_conflict_exception_json_err(&message.payload()[..], builder)
                            .map_err(|err| {
                                ::aws_smithy_eventstream::error::Error::unmarshalling(format!("failed to unmarshall conflictException: {}", err))
                            })?;
                        builder.set_meta(Some(generic));
                        return Ok(::aws_smithy_eventstream::frame::UnmarshalledMessage::Error(
                            crate::types::error::CodeInterpreterStreamOutputError::ConflictException(builder.build()),
                        ));
                    }
                    "internalServerException" => {
                        let mut builder = crate::types::error::builders::InternalServerExceptionBuilder::default();
                        builder = crate::protocol_serde::shape_internal_server_exception::de_internal_server_exception_json_err(
                            &message.payload()[..],
                            builder,
                        )
                        .map_err(|err| {
                            ::aws_smithy_eventstream::error::Error::unmarshalling(format!("failed to unmarshall internalServerException: {}", err))
                        })?;
                        builder.set_meta(Some(generic));
                        return Ok(::aws_smithy_eventstream::frame::UnmarshalledMessage::Error(
                            crate::types::error::CodeInterpreterStreamOutputError::InternalServerException(builder.build()),
                        ));
                    }
                    "resourceNotFoundException" => {
                        let mut builder = crate::types::error::builders::ResourceNotFoundExceptionBuilder::default();
                        builder = crate::protocol_serde::shape_resource_not_found_exception::de_resource_not_found_exception_json_err(
                            &message.payload()[..],
                            builder,
                        )
                        .map_err(|err| {
                            ::aws_smithy_eventstream::error::Error::unmarshalling(format!("failed to unmarshall resourceNotFoundException: {}", err))
                        })?;
                        builder.set_meta(Some(generic));
                        return Ok(::aws_smithy_eventstream::frame::UnmarshalledMessage::Error(
                            crate::types::error::CodeInterpreterStreamOutputError::ResourceNotFoundException(builder.build()),
                        ));
                    }
                    "serviceQuotaExceededException" => {
                        let mut builder = crate::types::error::builders::ServiceQuotaExceededExceptionBuilder::default();
                        builder = crate::protocol_serde::shape_service_quota_exceeded_exception::de_service_quota_exceeded_exception_json_err(
                            &message.payload()[..],
                            builder,
                        )
                        .map_err(|err| {
                            ::aws_smithy_eventstream::error::Error::unmarshalling(format!(
                                "failed to unmarshall serviceQuotaExceededException: {}",
                                err
                            ))
                        })?;
                        builder.set_meta(Some(generic));
                        return Ok(::aws_smithy_eventstream::frame::UnmarshalledMessage::Error(
                            crate::types::error::CodeInterpreterStreamOutputError::ServiceQuotaExceededException(builder.build()),
                        ));
                    }
                    "throttlingException" => {
                        let mut builder = crate::types::error::builders::ThrottlingExceptionBuilder::default();
                        builder =
                            crate::protocol_serde::shape_throttling_exception::de_throttling_exception_json_err(&message.payload()[..], builder)
                                .map_err(|err| {
                                    ::aws_smithy_eventstream::error::Error::unmarshalling(format!(
                                        "failed to unmarshall throttlingException: {}",
                                        err
                                    ))
                                })?;
                        builder.set_meta(Some(generic));
                        return Ok(::aws_smithy_eventstream::frame::UnmarshalledMessage::Error(
                            crate::types::error::CodeInterpreterStreamOutputError::ThrottlingException(builder.build()),
                        ));
                    }
                    "validationException" => {
                        let mut builder = crate::types::error::builders::ValidationExceptionBuilder::default();
                        builder =
                            crate::protocol_serde::shape_validation_exception::de_validation_exception_json_err(&message.payload()[..], builder)
                                .map_err(|err| {
                                    ::aws_smithy_eventstream::error::Error::unmarshalling(format!(
                                        "failed to unmarshall validationException: {}",
                                        err
                                    ))
                                })?;
                        builder.set_meta(Some(generic));
                        return Ok(::aws_smithy_eventstream::frame::UnmarshalledMessage::Error(
                            crate::types::error::CodeInterpreterStreamOutputError::ValidationException(
                                crate::serde_util::validation_exception_correct_errors(builder)
                                    .build()
                                    .map_err(|err| ::aws_smithy_eventstream::error::Error::unmarshalling(format!("{}", err)))?,
                            ),
                        ));
                    }
                    _ => {}
                }
                Ok(::aws_smithy_eventstream::frame::UnmarshalledMessage::Error(
                    crate::types::error::CodeInterpreterStreamOutputError::generic(generic),
                ))
            }
            value => {
                return Err(::aws_smithy_eventstream::error::Error::unmarshalling(format!(
                    "unrecognized :message-type: {}",
                    value
                )));
            }
        }
    }
}