#[non_exhaustive]
#[derive(Debug)]
pub struct AgenticRetrieveStreamOutputUnmarshaller;
impl AgenticRetrieveStreamOutputUnmarshaller {
pub fn new() -> Self {
AgenticRetrieveStreamOutputUnmarshaller
}
}
impl ::aws_smithy_eventstream::frame::UnmarshallMessage for AgenticRetrieveStreamOutputUnmarshaller {
type Output = crate::types::AgenticRetrieveStreamOutput;
type Error = crate::types::error::AgenticRetrieveStreamOutputError;
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() {
"traceEvent" => {
let parsed =
crate::protocol_serde::shape_agentic_retrieve_trace_event::de_agentic_retrieve_trace_event_payload(&message.payload()[..])
.map_err(|err| {
::aws_smithy_eventstream::error::Error::unmarshalling(format!("failed to unmarshall TraceEvent: {err}"))
})?;
Ok(::aws_smithy_eventstream::frame::UnmarshalledMessage::Event(
crate::types::AgenticRetrieveStreamOutput::TraceEvent(parsed),
))
}
"responseEvent" => {
let parsed = crate::protocol_serde::shape_agentic_retrieve_response_event::de_agentic_retrieve_response_event_payload(
&message.payload()[..],
)
.map_err(|err| ::aws_smithy_eventstream::error::Error::unmarshalling(format!("failed to unmarshall ResponseEvent: {err}")))?;
Ok(::aws_smithy_eventstream::frame::UnmarshalledMessage::Event(
crate::types::AgenticRetrieveStreamOutput::ResponseEvent(parsed),
))
}
"result" => {
let parsed =
crate::protocol_serde::shape_agentic_retrieve_result_event::de_agentic_retrieve_result_event_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::AgenticRetrieveStreamOutput::Result(parsed),
))
}
_unknown_variant => Ok(::aws_smithy_eventstream::frame::UnmarshalledMessage::Event(
crate::types::AgenticRetrieveStreamOutput::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::AgenticRetrieveStreamOutputError::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_cbor_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::AgenticRetrieveStreamOutputError::AccessDeniedException(
crate::serde_util::access_denied_exception_correct_errors(builder)
.build()
.map_err(|err| ::aws_smithy_eventstream::error::Error::unmarshalling(format!("{err}")))?,
),
));
}
"resourceNotFoundException" => {
let mut builder = crate::types::error::builders::ResourceNotFoundExceptionBuilder::default();
builder = crate::protocol_serde::shape_resource_not_found_exception::de_resource_not_found_exception_cbor_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::AgenticRetrieveStreamOutputError::ResourceNotFoundException(
crate::serde_util::resource_not_found_exception_correct_errors(builder)
.build()
.map_err(|err| ::aws_smithy_eventstream::error::Error::unmarshalling(format!("{err}")))?,
),
));
}
"internalServerException" => {
let mut builder = crate::types::error::builders::InternalServerExceptionBuilder::default();
builder = crate::protocol_serde::shape_internal_server_exception::de_internal_server_exception_cbor_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::AgenticRetrieveStreamOutputError::InternalServerException(
crate::serde_util::internal_server_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::AgenticRetrieveStreamOutputError::generic(generic),
))
}
value => {
return Err(::aws_smithy_eventstream::error::Error::unmarshalling(format!(
"unrecognized :message-type: {value}"
)));
}
}
}
}