aws-sdk-cloudwatchlogs 1.120.0

AWS SDK for Amazon CloudWatch Logs
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
#[non_exhaustive]
#[derive(Debug)]
pub struct GetLogObjectResponseStreamUnmarshaller;

impl GetLogObjectResponseStreamUnmarshaller {
    pub fn new() -> Self {
        GetLogObjectResponseStreamUnmarshaller
    }
}
impl ::aws_smithy_eventstream::frame::UnmarshallMessage for GetLogObjectResponseStreamUnmarshaller {
    type Output = crate::types::GetLogObjectResponseStream;
    type Error = crate::types::error::GetLogObjectResponseStreamError;
    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() {
                "fields" => {
                    let parsed = crate::protocol_serde::shape_fields_data::de_fields_data_payload(&message.payload()[..])
                        .map_err(|err| ::aws_smithy_eventstream::error::Error::unmarshalling(format!("failed to unmarshall Fields: {err}")))?;
                    Ok(::aws_smithy_eventstream::frame::UnmarshalledMessage::Event(
                        crate::types::GetLogObjectResponseStream::Fields(parsed),
                    ))
                }
                _unknown_variant => Ok(::aws_smithy_eventstream::frame::UnmarshalledMessage::Event(
                    crate::types::GetLogObjectResponseStream::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::GetLogObjectResponseStreamError::unhandled(err),
                        ))
                    }
                };
                if response_headers.smithy_type.as_str() == "InternalStreamingException" {
                    let mut builder = crate::types::error::builders::InternalStreamingExceptionBuilder::default();
                    builder = crate::protocol_serde::shape_internal_streaming_exception::de_internal_streaming_exception_json_err(
                        &message.payload()[..],
                        builder,
                    )
                    .map_err(|err| {
                        ::aws_smithy_eventstream::error::Error::unmarshalling(format!("failed to unmarshall InternalStreamingException: {err}"))
                    })?;
                    builder.set_meta(Some(generic));
                    return Ok(::aws_smithy_eventstream::frame::UnmarshalledMessage::Error(
                        crate::types::error::GetLogObjectResponseStreamError::InternalStreamingException(builder.build()),
                    ));
                }
                Ok(::aws_smithy_eventstream::frame::UnmarshalledMessage::Error(
                    crate::types::error::GetLogObjectResponseStreamError::generic(generic),
                ))
            }
            value => {
                return Err(::aws_smithy_eventstream::error::Error::unmarshalling(format!(
                    "unrecognized :message-type: {value}"
                )));
            }
        }
    }
}

#[non_exhaustive]
#[derive(Debug)]
pub struct StartLiveTailResponseStreamUnmarshaller;

impl StartLiveTailResponseStreamUnmarshaller {
    pub fn new() -> Self {
        StartLiveTailResponseStreamUnmarshaller
    }
}
impl ::aws_smithy_eventstream::frame::UnmarshallMessage for StartLiveTailResponseStreamUnmarshaller {
    type Output = crate::types::StartLiveTailResponseStream;
    type Error = crate::types::error::StartLiveTailResponseStreamError;
    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() {
                "sessionStart" => {
                    let parsed = crate::protocol_serde::shape_live_tail_session_start::de_live_tail_session_start_payload(&message.payload()[..])
                        .map_err(|err| ::aws_smithy_eventstream::error::Error::unmarshalling(format!("failed to unmarshall SessionStart: {err}")))?;
                    Ok(::aws_smithy_eventstream::frame::UnmarshalledMessage::Event(
                        crate::types::StartLiveTailResponseStream::SessionStart(parsed),
                    ))
                }
                "sessionUpdate" => {
                    let parsed = crate::protocol_serde::shape_live_tail_session_update::de_live_tail_session_update_payload(&message.payload()[..])
                        .map_err(|err| {
                        ::aws_smithy_eventstream::error::Error::unmarshalling(format!("failed to unmarshall SessionUpdate: {err}"))
                    })?;
                    Ok(::aws_smithy_eventstream::frame::UnmarshalledMessage::Event(
                        crate::types::StartLiveTailResponseStream::SessionUpdate(parsed),
                    ))
                }
                _unknown_variant => Ok(::aws_smithy_eventstream::frame::UnmarshalledMessage::Event(
                    crate::types::StartLiveTailResponseStream::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::StartLiveTailResponseStreamError::unhandled(err),
                        ))
                    }
                };
                match response_headers.smithy_type.as_str() {
                    "SessionTimeoutException" => {
                        let mut builder = crate::types::error::builders::SessionTimeoutExceptionBuilder::default();
                        builder = crate::protocol_serde::shape_session_timeout_exception::de_session_timeout_exception_json_err(
                            &message.payload()[..],
                            builder,
                        )
                        .map_err(|err| {
                            ::aws_smithy_eventstream::error::Error::unmarshalling(format!("failed to unmarshall SessionTimeoutException: {err}"))
                        })?;
                        builder.set_meta(Some(generic));
                        return Ok(::aws_smithy_eventstream::frame::UnmarshalledMessage::Error(
                            crate::types::error::StartLiveTailResponseStreamError::SessionTimeoutException(builder.build()),
                        ));
                    }
                    "SessionStreamingException" => {
                        let mut builder = crate::types::error::builders::SessionStreamingExceptionBuilder::default();
                        builder = crate::protocol_serde::shape_session_streaming_exception::de_session_streaming_exception_json_err(
                            &message.payload()[..],
                            builder,
                        )
                        .map_err(|err| {
                            ::aws_smithy_eventstream::error::Error::unmarshalling(format!("failed to unmarshall SessionStreamingException: {err}"))
                        })?;
                        builder.set_meta(Some(generic));
                        return Ok(::aws_smithy_eventstream::frame::UnmarshalledMessage::Error(
                            crate::types::error::StartLiveTailResponseStreamError::SessionStreamingException(builder.build()),
                        ));
                    }
                    _ => {}
                }
                Ok(::aws_smithy_eventstream::frame::UnmarshalledMessage::Error(
                    crate::types::error::StartLiveTailResponseStreamError::generic(generic),
                ))
            }
            value => {
                return Err(::aws_smithy_eventstream::error::Error::unmarshalling(format!(
                    "unrecognized :message-type: {value}"
                )));
            }
        }
    }
}