#[non_exhaustive]
#[derive(Debug)]
pub struct StartSpeechSynthesisStreamActionStreamErrorMarshaller;
impl StartSpeechSynthesisStreamActionStreamErrorMarshaller {
pub fn new() -> Self {
StartSpeechSynthesisStreamActionStreamErrorMarshaller
}
}
impl ::aws_smithy_eventstream::frame::MarshallMessage for StartSpeechSynthesisStreamActionStreamErrorMarshaller {
type Input = crate::types::error::StartSpeechSynthesisStreamActionStreamError;
fn marshall(
&self,
_input: Self::Input,
) -> std::result::Result<::aws_smithy_types::event_stream::Message, ::aws_smithy_eventstream::error::Error> {
let mut headers = Vec::new();
headers.push(::aws_smithy_types::event_stream::Header::new(
":message-type",
::aws_smithy_types::event_stream::HeaderValue::String("exception".into()),
));
let payload = Vec::new();
Ok(::aws_smithy_types::event_stream::Message::new_from_parts(headers, payload))
}
}
#[non_exhaustive]
#[derive(Debug)]
pub struct StartSpeechSynthesisStreamActionStreamMarshaller;
impl StartSpeechSynthesisStreamActionStreamMarshaller {
pub fn new() -> Self {
StartSpeechSynthesisStreamActionStreamMarshaller
}
}
impl ::aws_smithy_eventstream::frame::MarshallMessage for StartSpeechSynthesisStreamActionStreamMarshaller {
type Input = crate::types::StartSpeechSynthesisStreamActionStream;
fn marshall(&self, input: Self::Input) -> std::result::Result<::aws_smithy_types::event_stream::Message, ::aws_smithy_eventstream::error::Error> {
let mut headers = Vec::new();
headers.push(::aws_smithy_types::event_stream::Header::new(
":message-type",
::aws_smithy_types::event_stream::HeaderValue::String("event".into()),
));
let payload = match input {
Self::Input::TextEvent(inner) => {
headers.push(::aws_smithy_types::event_stream::Header::new(":event-type", ::aws_smithy_types::event_stream::HeaderValue::String("TextEvent".into())));
headers.push(::aws_smithy_types::event_stream::Header::new(":content-type", ::aws_smithy_types::event_stream::HeaderValue::String("application/json".into())));
crate::protocol_serde::shape_start_speech_synthesis_stream_action_stream::ser_text_event_payload(&inner)
.map_err(|err| ::aws_smithy_eventstream::error::Error::marshalling(format!("{err}")))?
}
Self::Input::CloseStreamEvent(inner) => {
headers.push(::aws_smithy_types::event_stream::Header::new(":event-type", ::aws_smithy_types::event_stream::HeaderValue::String("CloseStreamEvent".into())));
headers.push(::aws_smithy_types::event_stream::Header::new(":content-type", ::aws_smithy_types::event_stream::HeaderValue::String("application/json".into())));
crate::protocol_serde::shape_start_speech_synthesis_stream_action_stream::ser_close_stream_event_payload(&inner)
.map_err(|err| ::aws_smithy_eventstream::error::Error::marshalling(format!("{err}")))?
}
Self::Input::Unknown => return Err(
::aws_smithy_eventstream::error::Error::marshalling("Cannot serialize `StartSpeechSynthesisStreamActionStream::Unknown` for the request. The `Unknown` variant is intended for responses only. It occurs when an outdated client is used after a new enum variant was added on the server side.".to_owned())
)
}
;
Ok(::aws_smithy_types::event_stream::Message::new_from_parts(headers, payload))
}
}
#[non_exhaustive]
#[derive(Debug)]
pub struct StartSpeechSynthesisStreamEventStreamUnmarshaller;
impl StartSpeechSynthesisStreamEventStreamUnmarshaller {
pub fn new() -> Self {
StartSpeechSynthesisStreamEventStreamUnmarshaller
}
}
impl ::aws_smithy_eventstream::frame::UnmarshallMessage for StartSpeechSynthesisStreamEventStreamUnmarshaller {
type Output = crate::types::StartSpeechSynthesisStreamEventStream;
type Error = crate::types::error::StartSpeechSynthesisStreamEventStreamError;
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() {
"AudioEvent" => {
let mut builder = crate::types::builders::AudioEventBuilder::default();
let content_type = response_headers.content_type().unwrap_or_default();
if content_type != "application/octet-stream" {
return Err(::aws_smithy_eventstream::error::Error::unmarshalling(format!(
"expected :content-type to be 'application/octet-stream', but was '{content_type}'"
)));
}
builder = builder.set_audio_chunk(Some(::aws_smithy_types::Blob::new(message.payload().as_ref())));
Ok(::aws_smithy_eventstream::frame::UnmarshalledMessage::Event(
crate::types::StartSpeechSynthesisStreamEventStream::AudioEvent(builder.build()),
))
}
"StreamClosedEvent" => {
let parsed =
crate::protocol_serde::shape_stream_closed_event::de_stream_closed_event_payload(&message.payload()[..]).map_err(|err| {
::aws_smithy_eventstream::error::Error::unmarshalling(format!("failed to unmarshall StreamClosedEvent: {err}"))
})?;
Ok(::aws_smithy_eventstream::frame::UnmarshalledMessage::Event(
crate::types::StartSpeechSynthesisStreamEventStream::StreamClosedEvent(parsed),
))
}
_unknown_variant => Ok(::aws_smithy_eventstream::frame::UnmarshalledMessage::Event(
crate::types::StartSpeechSynthesisStreamEventStream::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::StartSpeechSynthesisStreamEventStreamError::unhandled(err),
))
}
};
match response_headers.smithy_type.as_str() {
"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::StartSpeechSynthesisStreamEventStreamError::ValidationException(
crate::serde_util::validation_exception_correct_errors(builder)
.build()
.map_err(|err| ::aws_smithy_eventstream::error::Error::unmarshalling(format!("{err}")))?,
),
));
}
"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::StartSpeechSynthesisStreamEventStreamError::ServiceQuotaExceededException(
crate::serde_util::service_quota_exceeded_exception_correct_errors(builder)
.build()
.map_err(|err| ::aws_smithy_eventstream::error::Error::unmarshalling(format!("{err}")))?,
),
));
}
"ServiceFailureException" => {
let mut builder = crate::types::error::builders::ServiceFailureExceptionBuilder::default();
builder = crate::protocol_serde::shape_service_failure_exception::de_service_failure_exception_json_err(
&message.payload()[..],
builder,
)
.map_err(|err| {
::aws_smithy_eventstream::error::Error::unmarshalling(format!("failed to unmarshall ServiceFailureException: {err}"))
})?;
builder.set_meta(Some(generic));
return Ok(::aws_smithy_eventstream::frame::UnmarshalledMessage::Error(
crate::types::error::StartSpeechSynthesisStreamEventStreamError::ServiceFailureException(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::StartSpeechSynthesisStreamEventStreamError::ThrottlingException(builder.build()),
));
}
_ => {}
}
Ok(::aws_smithy_eventstream::frame::UnmarshalledMessage::Error(
crate::types::error::StartSpeechSynthesisStreamEventStreamError::generic(generic),
))
}
value => {
return Err(::aws_smithy_eventstream::error::Error::unmarshalling(format!(
"unrecognized :message-type: {value}"
)));
}
}
}
}