rivet-chat 0.0.7

Rivet service enabling identities to send and receive chat messages
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub fn parse_http_generic_error(
	response: &http::Response<bytes::Bytes>,
) -> Result<aws_smithy_types::Error, aws_smithy_json::deserialize::Error> {
	crate::json_errors::parse_generic_error(response.body(), response.headers())
}

pub fn deser_structure_crate_error_internal_error_json_err(
	value: &[u8],
	mut builder: crate::error::internal_error::Builder,
) -> Result<crate::error::internal_error::Builder, aws_smithy_json::deserialize::Error> {
	let mut tokens_owned =
		aws_smithy_json::deserialize::json_token_iter(crate::json_deser::or_empty_doc(value))
			.peekable();
	let tokens = &mut tokens_owned;
	aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
	loop {
		match tokens.next().transpose()? {
			Some(aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
			Some(aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
				match key.to_unescaped()?.as_ref() {
					"code" => {
						builder = builder.set_code(
							aws_smithy_json::deserialize::token::expect_string_or_null(
								tokens.next(),
							)?
							.map(|s| s.to_unescaped().map(|u| u.into_owned()))
							.transpose()?,
						);
					}
					"message" => {
						builder = builder.set_message(
							aws_smithy_json::deserialize::token::expect_string_or_null(
								tokens.next(),
							)?
							.map(|s| s.to_unescaped().map(|u| u.into_owned()))
							.transpose()?,
						);
					}
					"metadata" => {
						builder = builder.set_metadata(Some(
							aws_smithy_json::deserialize::token::expect_document(tokens)?,
						));
					}
					_ => aws_smithy_json::deserialize::token::skip_value(tokens)?,
				}
			}
			other => {
				return Err(aws_smithy_json::deserialize::Error::custom(format!(
					"expected object key or end object, found: {:?}",
					other
				)))
			}
		}
	}
	if tokens.next().is_some() {
		return Err(aws_smithy_json::deserialize::Error::custom(
			"found more JSON tokens after completing parsing",
		));
	}
	Ok(builder)
}

pub fn deser_structure_crate_error_rate_limit_error_json_err(
	value: &[u8],
	mut builder: crate::error::rate_limit_error::Builder,
) -> Result<crate::error::rate_limit_error::Builder, aws_smithy_json::deserialize::Error> {
	let mut tokens_owned =
		aws_smithy_json::deserialize::json_token_iter(crate::json_deser::or_empty_doc(value))
			.peekable();
	let tokens = &mut tokens_owned;
	aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
	loop {
		match tokens.next().transpose()? {
			Some(aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
			Some(aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
				match key.to_unescaped()?.as_ref() {
					"code" => {
						builder = builder.set_code(
							aws_smithy_json::deserialize::token::expect_string_or_null(
								tokens.next(),
							)?
							.map(|s| s.to_unescaped().map(|u| u.into_owned()))
							.transpose()?,
						);
					}
					"message" => {
						builder = builder.set_message(
							aws_smithy_json::deserialize::token::expect_string_or_null(
								tokens.next(),
							)?
							.map(|s| s.to_unescaped().map(|u| u.into_owned()))
							.transpose()?,
						);
					}
					"metadata" => {
						builder = builder.set_metadata(Some(
							aws_smithy_json::deserialize::token::expect_document(tokens)?,
						));
					}
					_ => aws_smithy_json::deserialize::token::skip_value(tokens)?,
				}
			}
			other => {
				return Err(aws_smithy_json::deserialize::Error::custom(format!(
					"expected object key or end object, found: {:?}",
					other
				)))
			}
		}
	}
	if tokens.next().is_some() {
		return Err(aws_smithy_json::deserialize::Error::custom(
			"found more JSON tokens after completing parsing",
		));
	}
	Ok(builder)
}

pub fn deser_structure_crate_error_forbidden_error_json_err(
	value: &[u8],
	mut builder: crate::error::forbidden_error::Builder,
) -> Result<crate::error::forbidden_error::Builder, aws_smithy_json::deserialize::Error> {
	let mut tokens_owned =
		aws_smithy_json::deserialize::json_token_iter(crate::json_deser::or_empty_doc(value))
			.peekable();
	let tokens = &mut tokens_owned;
	aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
	loop {
		match tokens.next().transpose()? {
			Some(aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
			Some(aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
				match key.to_unescaped()?.as_ref() {
					"code" => {
						builder = builder.set_code(
							aws_smithy_json::deserialize::token::expect_string_or_null(
								tokens.next(),
							)?
							.map(|s| s.to_unescaped().map(|u| u.into_owned()))
							.transpose()?,
						);
					}
					"message" => {
						builder = builder.set_message(
							aws_smithy_json::deserialize::token::expect_string_or_null(
								tokens.next(),
							)?
							.map(|s| s.to_unescaped().map(|u| u.into_owned()))
							.transpose()?,
						);
					}
					"metadata" => {
						builder = builder.set_metadata(Some(
							aws_smithy_json::deserialize::token::expect_document(tokens)?,
						));
					}
					_ => aws_smithy_json::deserialize::token::skip_value(tokens)?,
				}
			}
			other => {
				return Err(aws_smithy_json::deserialize::Error::custom(format!(
					"expected object key or end object, found: {:?}",
					other
				)))
			}
		}
	}
	if tokens.next().is_some() {
		return Err(aws_smithy_json::deserialize::Error::custom(
			"found more JSON tokens after completing parsing",
		));
	}
	Ok(builder)
}

pub fn deser_structure_crate_error_unauthorized_error_json_err(
	value: &[u8],
	mut builder: crate::error::unauthorized_error::Builder,
) -> Result<crate::error::unauthorized_error::Builder, aws_smithy_json::deserialize::Error> {
	let mut tokens_owned =
		aws_smithy_json::deserialize::json_token_iter(crate::json_deser::or_empty_doc(value))
			.peekable();
	let tokens = &mut tokens_owned;
	aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
	loop {
		match tokens.next().transpose()? {
			Some(aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
			Some(aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
				match key.to_unescaped()?.as_ref() {
					"code" => {
						builder = builder.set_code(
							aws_smithy_json::deserialize::token::expect_string_or_null(
								tokens.next(),
							)?
							.map(|s| s.to_unescaped().map(|u| u.into_owned()))
							.transpose()?,
						);
					}
					"message" => {
						builder = builder.set_message(
							aws_smithy_json::deserialize::token::expect_string_or_null(
								tokens.next(),
							)?
							.map(|s| s.to_unescaped().map(|u| u.into_owned()))
							.transpose()?,
						);
					}
					"metadata" => {
						builder = builder.set_metadata(Some(
							aws_smithy_json::deserialize::token::expect_document(tokens)?,
						));
					}
					_ => aws_smithy_json::deserialize::token::skip_value(tokens)?,
				}
			}
			other => {
				return Err(aws_smithy_json::deserialize::Error::custom(format!(
					"expected object key or end object, found: {:?}",
					other
				)))
			}
		}
	}
	if tokens.next().is_some() {
		return Err(aws_smithy_json::deserialize::Error::custom(
			"found more JSON tokens after completing parsing",
		));
	}
	Ok(builder)
}

pub fn deser_structure_crate_error_not_found_error_json_err(
	value: &[u8],
	mut builder: crate::error::not_found_error::Builder,
) -> Result<crate::error::not_found_error::Builder, aws_smithy_json::deserialize::Error> {
	let mut tokens_owned =
		aws_smithy_json::deserialize::json_token_iter(crate::json_deser::or_empty_doc(value))
			.peekable();
	let tokens = &mut tokens_owned;
	aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
	loop {
		match tokens.next().transpose()? {
			Some(aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
			Some(aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
				match key.to_unescaped()?.as_ref() {
					"code" => {
						builder = builder.set_code(
							aws_smithy_json::deserialize::token::expect_string_or_null(
								tokens.next(),
							)?
							.map(|s| s.to_unescaped().map(|u| u.into_owned()))
							.transpose()?,
						);
					}
					"message" => {
						builder = builder.set_message(
							aws_smithy_json::deserialize::token::expect_string_or_null(
								tokens.next(),
							)?
							.map(|s| s.to_unescaped().map(|u| u.into_owned()))
							.transpose()?,
						);
					}
					"metadata" => {
						builder = builder.set_metadata(Some(
							aws_smithy_json::deserialize::token::expect_document(tokens)?,
						));
					}
					_ => aws_smithy_json::deserialize::token::skip_value(tokens)?,
				}
			}
			other => {
				return Err(aws_smithy_json::deserialize::Error::custom(format!(
					"expected object key or end object, found: {:?}",
					other
				)))
			}
		}
	}
	if tokens.next().is_some() {
		return Err(aws_smithy_json::deserialize::Error::custom(
			"found more JSON tokens after completing parsing",
		));
	}
	Ok(builder)
}

pub fn deser_structure_crate_error_bad_request_error_json_err(
	value: &[u8],
	mut builder: crate::error::bad_request_error::Builder,
) -> Result<crate::error::bad_request_error::Builder, aws_smithy_json::deserialize::Error> {
	let mut tokens_owned =
		aws_smithy_json::deserialize::json_token_iter(crate::json_deser::or_empty_doc(value))
			.peekable();
	let tokens = &mut tokens_owned;
	aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
	loop {
		match tokens.next().transpose()? {
			Some(aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
			Some(aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
				match key.to_unescaped()?.as_ref() {
					"code" => {
						builder = builder.set_code(
							aws_smithy_json::deserialize::token::expect_string_or_null(
								tokens.next(),
							)?
							.map(|s| s.to_unescaped().map(|u| u.into_owned()))
							.transpose()?,
						);
					}
					"message" => {
						builder = builder.set_message(
							aws_smithy_json::deserialize::token::expect_string_or_null(
								tokens.next(),
							)?
							.map(|s| s.to_unescaped().map(|u| u.into_owned()))
							.transpose()?,
						);
					}
					"metadata" => {
						builder = builder.set_metadata(Some(
							aws_smithy_json::deserialize::token::expect_document(tokens)?,
						));
					}
					_ => aws_smithy_json::deserialize::token::skip_value(tokens)?,
				}
			}
			other => {
				return Err(aws_smithy_json::deserialize::Error::custom(format!(
					"expected object key or end object, found: {:?}",
					other
				)))
			}
		}
	}
	if tokens.next().is_some() {
		return Err(aws_smithy_json::deserialize::Error::custom(
			"found more JSON tokens after completing parsing",
		));
	}
	Ok(builder)
}

pub fn deser_operation_crate_operation_get_direct_thread(
	value: &[u8],
	mut builder: crate::output::get_direct_thread_output::Builder,
) -> Result<crate::output::get_direct_thread_output::Builder, aws_smithy_json::deserialize::Error> {
	let mut tokens_owned =
		aws_smithy_json::deserialize::json_token_iter(crate::json_deser::or_empty_doc(value))
			.peekable();
	let tokens = &mut tokens_owned;
	aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
	loop {
		match tokens.next().transpose()? {
			Some(aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
			Some(aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
				match key.to_unescaped()?.as_ref() {
					"identity" => {
						builder = builder.set_identity(
							crate::json_deser::deser_structure_crate_model_identity_handle(tokens)?,
						);
					}
					"thread_id" => {
						builder = builder.set_thread_id(
							aws_smithy_json::deserialize::token::expect_string_or_null(
								tokens.next(),
							)?
							.map(|s| s.to_unescaped().map(|u| u.into_owned()))
							.transpose()?,
						);
					}
					_ => aws_smithy_json::deserialize::token::skip_value(tokens)?,
				}
			}
			other => {
				return Err(aws_smithy_json::deserialize::Error::custom(format!(
					"expected object key or end object, found: {:?}",
					other
				)))
			}
		}
	}
	if tokens.next().is_some() {
		return Err(aws_smithy_json::deserialize::Error::custom(
			"found more JSON tokens after completing parsing",
		));
	}
	Ok(builder)
}

pub fn deser_operation_crate_operation_get_thread_history(
	value: &[u8],
	mut builder: crate::output::get_thread_history_output::Builder,
) -> Result<crate::output::get_thread_history_output::Builder, aws_smithy_json::deserialize::Error>
{
	let mut tokens_owned =
		aws_smithy_json::deserialize::json_token_iter(crate::json_deser::or_empty_doc(value))
			.peekable();
	let tokens = &mut tokens_owned;
	aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
	loop {
		match tokens.next().transpose()? {
			Some(aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
			Some(aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
				match key.to_unescaped()?.as_ref() {
					"chat_messages" => {
						builder = builder.set_chat_messages(
							crate::json_deser::deser_list_rivet_chat_chat_messages(tokens)?,
						);
					}
					_ => aws_smithy_json::deserialize::token::skip_value(tokens)?,
				}
			}
			other => {
				return Err(aws_smithy_json::deserialize::Error::custom(format!(
					"expected object key or end object, found: {:?}",
					other
				)))
			}
		}
	}
	if tokens.next().is_some() {
		return Err(aws_smithy_json::deserialize::Error::custom(
			"found more JSON tokens after completing parsing",
		));
	}
	Ok(builder)
}

pub fn deser_operation_crate_operation_get_thread_topic(
	value: &[u8],
	mut builder: crate::output::get_thread_topic_output::Builder,
) -> Result<crate::output::get_thread_topic_output::Builder, aws_smithy_json::deserialize::Error> {
	let mut tokens_owned =
		aws_smithy_json::deserialize::json_token_iter(crate::json_deser::or_empty_doc(value))
			.peekable();
	let tokens = &mut tokens_owned;
	aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
	loop {
		match tokens.next().transpose()? {
			Some(aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
			Some(aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
				match key.to_unescaped()?.as_ref() {
					"topic" => {
						builder = builder.set_topic(
							crate::json_deser::deser_union_crate_model_chat_simple_topic(tokens)?,
						);
					}
					_ => aws_smithy_json::deserialize::token::skip_value(tokens)?,
				}
			}
			other => {
				return Err(aws_smithy_json::deserialize::Error::custom(format!(
					"expected object key or end object, found: {:?}",
					other
				)))
			}
		}
	}
	if tokens.next().is_some() {
		return Err(aws_smithy_json::deserialize::Error::custom(
			"found more JSON tokens after completing parsing",
		));
	}
	Ok(builder)
}

pub fn deser_operation_crate_operation_send_chat_message(
	value: &[u8],
	mut builder: crate::output::send_chat_message_output::Builder,
) -> Result<crate::output::send_chat_message_output::Builder, aws_smithy_json::deserialize::Error> {
	let mut tokens_owned =
		aws_smithy_json::deserialize::json_token_iter(crate::json_deser::or_empty_doc(value))
			.peekable();
	let tokens = &mut tokens_owned;
	aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
	loop {
		match tokens.next().transpose()? {
			Some(aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
			Some(aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
				match key.to_unescaped()?.as_ref() {
					"chat_message_id" => {
						builder = builder.set_chat_message_id(
							aws_smithy_json::deserialize::token::expect_string_or_null(
								tokens.next(),
							)?
							.map(|s| s.to_unescaped().map(|u| u.into_owned()))
							.transpose()?,
						);
					}
					_ => aws_smithy_json::deserialize::token::skip_value(tokens)?,
				}
			}
			other => {
				return Err(aws_smithy_json::deserialize::Error::custom(format!(
					"expected object key or end object, found: {:?}",
					other
				)))
			}
		}
	}
	if tokens.next().is_some() {
		return Err(aws_smithy_json::deserialize::Error::custom(
			"found more JSON tokens after completing parsing",
		));
	}
	Ok(builder)
}

pub fn deser_operation_crate_operation_watch_thread(
	value: &[u8],
	mut builder: crate::output::watch_thread_output::Builder,
) -> Result<crate::output::watch_thread_output::Builder, aws_smithy_json::deserialize::Error> {
	let mut tokens_owned =
		aws_smithy_json::deserialize::json_token_iter(crate::json_deser::or_empty_doc(value))
			.peekable();
	let tokens = &mut tokens_owned;
	aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
	loop {
		match tokens.next().transpose()? {
			Some(aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
			Some(aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
				match key.to_unescaped()?.as_ref() {
					"chat_messages" => {
						builder = builder.set_chat_messages(
							crate::json_deser::deser_list_rivet_chat_chat_messages(tokens)?,
						);
					}
					"typing_statuses" => {
						builder = builder.set_typing_statuses(
							crate::json_deser::deser_list_rivet_chat_chat_identity_typing_statuses(
								tokens,
							)?,
						);
					}
					"watch" => {
						builder = builder.set_watch(
							crate::json_deser::deser_structure_crate_model_watch_response(tokens)?,
						);
					}
					_ => aws_smithy_json::deserialize::token::skip_value(tokens)?,
				}
			}
			other => {
				return Err(aws_smithy_json::deserialize::Error::custom(format!(
					"expected object key or end object, found: {:?}",
					other
				)))
			}
		}
	}
	if tokens.next().is_some() {
		return Err(aws_smithy_json::deserialize::Error::custom(
			"found more JSON tokens after completing parsing",
		));
	}
	Ok(builder)
}

pub fn or_empty_doc(data: &[u8]) -> &[u8] {
	if data.is_empty() {
		b"{}"
	} else {
		data
	}
}

pub fn deser_structure_crate_model_identity_handle<'a, I>(
	tokens: &mut std::iter::Peekable<I>,
) -> Result<Option<crate::model::IdentityHandle>, aws_smithy_json::deserialize::Error>
where
	I: Iterator<
		Item = Result<aws_smithy_json::deserialize::Token<'a>, aws_smithy_json::deserialize::Error>,
	>,
{
	match tokens.next().transpose()? {
		Some(aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
		Some(aws_smithy_json::deserialize::Token::StartObject { .. }) => {
			#[allow(unused_mut)]
			let mut builder = crate::model::IdentityHandle::builder();
			loop {
				match tokens.next().transpose()? {
					Some(aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
					Some(aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
						match key.to_unescaped()?.as_ref() {
							"identity_id" => {
								builder = builder.set_identity_id(
									aws_smithy_json::deserialize::token::expect_string_or_null(
										tokens.next(),
									)?
									.map(|s| s.to_unescaped().map(|u| u.into_owned()))
									.transpose()?,
								);
							}
							"display_name" => {
								builder = builder.set_display_name(
									aws_smithy_json::deserialize::token::expect_string_or_null(
										tokens.next(),
									)?
									.map(|s| s.to_unescaped().map(|u| u.into_owned()))
									.transpose()?,
								);
							}
							"account_number" => {
								builder = builder.set_account_number(
									aws_smithy_json::deserialize::token::expect_number_or_null(
										tokens.next(),
									)?
									.map(|v| v.to_i32()),
								);
							}
							"avatar_url" => {
								builder = builder.set_avatar_url(
									aws_smithy_json::deserialize::token::expect_string_or_null(
										tokens.next(),
									)?
									.map(|s| s.to_unescaped().map(|u| u.into_owned()))
									.transpose()?,
								);
							}
							"presence" => {
								builder = builder.set_presence(
                                    crate::json_deser::deser_structure_crate_model_identity_presence(tokens)?
                                );
							}
							"party" => {
								builder = builder.set_party(
									crate::json_deser::deser_structure_crate_model_party_handle(
										tokens,
									)?,
								);
							}
							"is_registered" => {
								builder = builder.set_is_registered(
									aws_smithy_json::deserialize::token::expect_bool_or_null(
										tokens.next(),
									)?,
								);
							}
							"external" => {
								builder = builder.set_external(
                                    crate::json_deser::deser_structure_crate_model_identity_external_links(tokens)?
                                );
							}
							_ => aws_smithy_json::deserialize::token::skip_value(tokens)?,
						}
					}
					other => {
						return Err(aws_smithy_json::deserialize::Error::custom(format!(
							"expected object key or end object, found: {:?}",
							other
						)))
					}
				}
			}
			Ok(Some(builder.build()))
		}
		_ => Err(aws_smithy_json::deserialize::Error::custom(
			"expected start object or null",
		)),
	}
}

#[allow(clippy::type_complexity, non_snake_case)]
pub fn deser_list_rivet_chat_chat_messages<'a, I>(
	tokens: &mut std::iter::Peekable<I>,
) -> Result<Option<std::vec::Vec<crate::model::ChatMessage>>, aws_smithy_json::deserialize::Error>
where
	I: Iterator<
		Item = Result<aws_smithy_json::deserialize::Token<'a>, aws_smithy_json::deserialize::Error>,
	>,
{
	match tokens.next().transpose()? {
		Some(aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
		Some(aws_smithy_json::deserialize::Token::StartArray { .. }) => {
			let mut items = Vec::new();
			loop {
				match tokens.peek() {
					Some(Ok(aws_smithy_json::deserialize::Token::EndArray { .. })) => {
						tokens.next().transpose().unwrap();
						break;
					}
					_ => {
						let value =
							crate::json_deser::deser_structure_crate_model_chat_message(tokens)?;
						if let Some(value) = value {
							items.push(value);
						}
					}
				}
			}
			Ok(Some(items))
		}
		_ => Err(aws_smithy_json::deserialize::Error::custom(
			"expected start array or null",
		)),
	}
}

pub fn deser_union_crate_model_chat_simple_topic<'a, I>(
	tokens: &mut std::iter::Peekable<I>,
) -> Result<Option<crate::model::ChatSimpleTopic>, aws_smithy_json::deserialize::Error>
where
	I: Iterator<
		Item = Result<aws_smithy_json::deserialize::Token<'a>, aws_smithy_json::deserialize::Error>,
	>,
{
	let mut variant = None;
	match tokens.next().transpose()? {
		Some(aws_smithy_json::deserialize::Token::ValueNull { .. }) => return Ok(None),
		Some(aws_smithy_json::deserialize::Token::StartObject { .. }) => loop {
			match tokens.next().transpose()? {
				Some(aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
				Some(aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
					if variant.is_some() {
						return Err(aws_smithy_json::deserialize::Error::custom(
							"encountered mixed variants in union",
						));
					}
					variant = match key.to_unescaped()?.as_ref() {
                            "group" => {
                                Some(crate::model::ChatSimpleTopic::Group(
                                    crate::json_deser::deser_structure_crate_model_chat_simple_topic_group(tokens)?
                                    .ok_or_else(|| aws_smithy_json::deserialize::Error::custom("value for 'group' cannot be null"))?
                                ))
                            }
                            "party" => {
                                Some(crate::model::ChatSimpleTopic::Party(
                                    crate::json_deser::deser_structure_crate_model_chat_simple_topic_party(tokens)?
                                    .ok_or_else(|| aws_smithy_json::deserialize::Error::custom("value for 'party' cannot be null"))?
                                ))
                            }
                            "direct" => {
                                Some(crate::model::ChatSimpleTopic::Direct(
                                    crate::json_deser::deser_structure_crate_model_chat_simple_topic_direct(tokens)?
                                    .ok_or_else(|| aws_smithy_json::deserialize::Error::custom("value for 'direct' cannot be null"))?
                                ))
                            }
                            _ => {
                                                                      aws_smithy_json::deserialize::token::skip_value(tokens)?;
                                                                      Some(crate::model::ChatSimpleTopic::Unknown)
                                                                    }
                        };
				}
				other => {
					return Err(aws_smithy_json::deserialize::Error::custom(format!(
						"expected object key or end object, found: {:?}",
						other
					)))
				}
			}
		},
		_ => {
			return Err(aws_smithy_json::deserialize::Error::custom(
				"expected start object or null",
			))
		}
	}
	Ok(variant)
}

#[allow(clippy::type_complexity, non_snake_case)]
pub fn deser_list_rivet_chat_chat_identity_typing_statuses<'a, I>(
	tokens: &mut std::iter::Peekable<I>,
) -> Result<
	Option<std::vec::Vec<crate::model::ChatIdentityTypingStatus>>,
	aws_smithy_json::deserialize::Error,
>
where
	I: Iterator<
		Item = Result<aws_smithy_json::deserialize::Token<'a>, aws_smithy_json::deserialize::Error>,
	>,
{
	match tokens.next().transpose()? {
		Some(aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
		Some(aws_smithy_json::deserialize::Token::StartArray { .. }) => {
			let mut items = Vec::new();
			loop {
				match tokens.peek() {
					Some(Ok(aws_smithy_json::deserialize::Token::EndArray { .. })) => {
						tokens.next().transpose().unwrap();
						break;
					}
					_ => {
						let value =
                            crate::json_deser::deser_structure_crate_model_chat_identity_typing_status(tokens)?
                        ;
						if let Some(value) = value {
							items.push(value);
						}
					}
				}
			}
			Ok(Some(items))
		}
		_ => Err(aws_smithy_json::deserialize::Error::custom(
			"expected start array or null",
		)),
	}
}

pub fn deser_structure_crate_model_watch_response<'a, I>(
	tokens: &mut std::iter::Peekable<I>,
) -> Result<Option<crate::model::WatchResponse>, aws_smithy_json::deserialize::Error>
where
	I: Iterator<
		Item = Result<aws_smithy_json::deserialize::Token<'a>, aws_smithy_json::deserialize::Error>,
	>,
{
	match tokens.next().transpose()? {
		Some(aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
		Some(aws_smithy_json::deserialize::Token::StartObject { .. }) => {
			#[allow(unused_mut)]
			let mut builder = crate::model::WatchResponse::builder();
			loop {
				match tokens.next().transpose()? {
					Some(aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
					Some(aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
						match key.to_unescaped()?.as_ref() {
							"index" => {
								builder = builder.set_index(
									aws_smithy_json::deserialize::token::expect_string_or_null(
										tokens.next(),
									)?
									.map(|s| s.to_unescaped().map(|u| u.into_owned()))
									.transpose()?,
								);
							}
							_ => aws_smithy_json::deserialize::token::skip_value(tokens)?,
						}
					}
					other => {
						return Err(aws_smithy_json::deserialize::Error::custom(format!(
							"expected object key or end object, found: {:?}",
							other
						)))
					}
				}
			}
			Ok(Some(builder.build()))
		}
		_ => Err(aws_smithy_json::deserialize::Error::custom(
			"expected start object or null",
		)),
	}
}

pub fn deser_structure_crate_model_identity_presence<'a, I>(
	tokens: &mut std::iter::Peekable<I>,
) -> Result<Option<crate::model::IdentityPresence>, aws_smithy_json::deserialize::Error>
where
	I: Iterator<
		Item = Result<aws_smithy_json::deserialize::Token<'a>, aws_smithy_json::deserialize::Error>,
	>,
{
	match tokens.next().transpose()? {
		Some(aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
		Some(aws_smithy_json::deserialize::Token::StartObject { .. }) => {
			#[allow(unused_mut)]
			let mut builder = crate::model::IdentityPresence::builder();
			loop {
				match tokens.next().transpose()? {
					Some(aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
					Some(aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
						match key.to_unescaped()?.as_ref() {
							"update_ts" => {
								builder = builder.set_update_ts(
									aws_smithy_json::deserialize::token::expect_timestamp_or_null(
										tokens.next(),
										aws_smithy_types::date_time::Format::DateTime,
									)?,
								);
							}
							"status" => {
								builder = builder.set_status(
									aws_smithy_json::deserialize::token::expect_string_or_null(
										tokens.next(),
									)?
									.map(|s| {
										s.to_unescaped()
											.map(|u| crate::model::IdentityStatus::from(u.as_ref()))
									})
									.transpose()?,
								);
							}
							"game_activity" => {
								builder = builder.set_game_activity(
                                    crate::json_deser::deser_structure_crate_model_identity_game_activity(tokens)?
                                );
							}
							_ => aws_smithy_json::deserialize::token::skip_value(tokens)?,
						}
					}
					other => {
						return Err(aws_smithy_json::deserialize::Error::custom(format!(
							"expected object key or end object, found: {:?}",
							other
						)))
					}
				}
			}
			Ok(Some(builder.build()))
		}
		_ => Err(aws_smithy_json::deserialize::Error::custom(
			"expected start object or null",
		)),
	}
}

pub fn deser_structure_crate_model_party_handle<'a, I>(
	tokens: &mut std::iter::Peekable<I>,
) -> Result<Option<crate::model::PartyHandle>, aws_smithy_json::deserialize::Error>
where
	I: Iterator<
		Item = Result<aws_smithy_json::deserialize::Token<'a>, aws_smithy_json::deserialize::Error>,
	>,
{
	match tokens.next().transpose()? {
		Some(aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
		Some(aws_smithy_json::deserialize::Token::StartObject { .. }) => {
			#[allow(unused_mut)]
			let mut builder = crate::model::PartyHandle::builder();
			loop {
				match tokens.next().transpose()? {
					Some(aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
					Some(aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
						match key.to_unescaped()?.as_ref() {
							"party_id" => {
								builder = builder.set_party_id(
									aws_smithy_json::deserialize::token::expect_string_or_null(
										tokens.next(),
									)?
									.map(|s| s.to_unescaped().map(|u| u.into_owned()))
									.transpose()?,
								);
							}
							"create_ts" => {
								builder = builder.set_create_ts(
									aws_smithy_json::deserialize::token::expect_timestamp_or_null(
										tokens.next(),
										aws_smithy_types::date_time::Format::DateTime,
									)?,
								);
							}
							"activity" => {
								builder = builder.set_activity(
									crate::json_deser::deser_union_crate_model_party_activity(
										tokens,
									)?,
								);
							}
							"external" => {
								builder = builder.set_external(
                                    crate::json_deser::deser_structure_crate_model_party_external_links(tokens)?
                                );
							}
							_ => aws_smithy_json::deserialize::token::skip_value(tokens)?,
						}
					}
					other => {
						return Err(aws_smithy_json::deserialize::Error::custom(format!(
							"expected object key or end object, found: {:?}",
							other
						)))
					}
				}
			}
			Ok(Some(builder.build()))
		}
		_ => Err(aws_smithy_json::deserialize::Error::custom(
			"expected start object or null",
		)),
	}
}

pub fn deser_structure_crate_model_identity_external_links<'a, I>(
	tokens: &mut std::iter::Peekable<I>,
) -> Result<Option<crate::model::IdentityExternalLinks>, aws_smithy_json::deserialize::Error>
where
	I: Iterator<
		Item = Result<aws_smithy_json::deserialize::Token<'a>, aws_smithy_json::deserialize::Error>,
	>,
{
	match tokens.next().transpose()? {
		Some(aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
		Some(aws_smithy_json::deserialize::Token::StartObject { .. }) => {
			#[allow(unused_mut)]
			let mut builder = crate::model::IdentityExternalLinks::builder();
			loop {
				match tokens.next().transpose()? {
					Some(aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
					Some(aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
						match key.to_unescaped()?.as_ref() {
							"profile" => {
								builder = builder.set_profile(
									aws_smithy_json::deserialize::token::expect_string_or_null(
										tokens.next(),
									)?
									.map(|s| s.to_unescaped().map(|u| u.into_owned()))
									.transpose()?,
								);
							}
							"settings" => {
								builder = builder.set_settings(
									aws_smithy_json::deserialize::token::expect_string_or_null(
										tokens.next(),
									)?
									.map(|s| s.to_unescaped().map(|u| u.into_owned()))
									.transpose()?,
								);
							}
							"chat" => {
								builder = builder.set_chat(
									aws_smithy_json::deserialize::token::expect_string_or_null(
										tokens.next(),
									)?
									.map(|s| s.to_unescaped().map(|u| u.into_owned()))
									.transpose()?,
								);
							}
							_ => aws_smithy_json::deserialize::token::skip_value(tokens)?,
						}
					}
					other => {
						return Err(aws_smithy_json::deserialize::Error::custom(format!(
							"expected object key or end object, found: {:?}",
							other
						)))
					}
				}
			}
			Ok(Some(builder.build()))
		}
		_ => Err(aws_smithy_json::deserialize::Error::custom(
			"expected start object or null",
		)),
	}
}

pub fn deser_structure_crate_model_chat_message<'a, I>(
	tokens: &mut std::iter::Peekable<I>,
) -> Result<Option<crate::model::ChatMessage>, aws_smithy_json::deserialize::Error>
where
	I: Iterator<
		Item = Result<aws_smithy_json::deserialize::Token<'a>, aws_smithy_json::deserialize::Error>,
	>,
{
	match tokens.next().transpose()? {
		Some(aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
		Some(aws_smithy_json::deserialize::Token::StartObject { .. }) => {
			#[allow(unused_mut)]
			let mut builder = crate::model::ChatMessage::builder();
			loop {
				match tokens.next().transpose()? {
					Some(aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
					Some(aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
						match key.to_unescaped()?.as_ref() {
							"chat_message_id" => {
								builder = builder.set_chat_message_id(
									aws_smithy_json::deserialize::token::expect_string_or_null(
										tokens.next(),
									)?
									.map(|s| s.to_unescaped().map(|u| u.into_owned()))
									.transpose()?,
								);
							}
							"thread_id" => {
								builder = builder.set_thread_id(
									aws_smithy_json::deserialize::token::expect_string_or_null(
										tokens.next(),
									)?
									.map(|s| s.to_unescaped().map(|u| u.into_owned()))
									.transpose()?,
								);
							}
							"send_ts" => {
								builder = builder.set_send_ts(
									aws_smithy_json::deserialize::token::expect_timestamp_or_null(
										tokens.next(),
										aws_smithy_types::date_time::Format::DateTime,
									)?,
								);
							}
							"body" => {
								builder = builder.set_body(
									crate::json_deser::deser_union_crate_model_chat_message_body(
										tokens,
									)?,
								);
							}
							_ => aws_smithy_json::deserialize::token::skip_value(tokens)?,
						}
					}
					other => {
						return Err(aws_smithy_json::deserialize::Error::custom(format!(
							"expected object key or end object, found: {:?}",
							other
						)))
					}
				}
			}
			Ok(Some(builder.build()))
		}
		_ => Err(aws_smithy_json::deserialize::Error::custom(
			"expected start object or null",
		)),
	}
}

pub fn deser_structure_crate_model_chat_simple_topic_group<'a, I>(
	tokens: &mut std::iter::Peekable<I>,
) -> Result<Option<crate::model::ChatSimpleTopicGroup>, aws_smithy_json::deserialize::Error>
where
	I: Iterator<
		Item = Result<aws_smithy_json::deserialize::Token<'a>, aws_smithy_json::deserialize::Error>,
	>,
{
	match tokens.next().transpose()? {
		Some(aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
		Some(aws_smithy_json::deserialize::Token::StartObject { .. }) => {
			#[allow(unused_mut)]
			let mut builder = crate::model::ChatSimpleTopicGroup::builder();
			loop {
				match tokens.next().transpose()? {
					Some(aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
					Some(aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
						match key.to_unescaped()?.as_ref() {
							"group_id" => {
								builder = builder.set_group_id(
									aws_smithy_json::deserialize::token::expect_string_or_null(
										tokens.next(),
									)?
									.map(|s| s.to_unescaped().map(|u| u.into_owned()))
									.transpose()?,
								);
							}
							_ => aws_smithy_json::deserialize::token::skip_value(tokens)?,
						}
					}
					other => {
						return Err(aws_smithy_json::deserialize::Error::custom(format!(
							"expected object key or end object, found: {:?}",
							other
						)))
					}
				}
			}
			Ok(Some(builder.build()))
		}
		_ => Err(aws_smithy_json::deserialize::Error::custom(
			"expected start object or null",
		)),
	}
}

pub fn deser_structure_crate_model_chat_simple_topic_party<'a, I>(
	tokens: &mut std::iter::Peekable<I>,
) -> Result<Option<crate::model::ChatSimpleTopicParty>, aws_smithy_json::deserialize::Error>
where
	I: Iterator<
		Item = Result<aws_smithy_json::deserialize::Token<'a>, aws_smithy_json::deserialize::Error>,
	>,
{
	match tokens.next().transpose()? {
		Some(aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
		Some(aws_smithy_json::deserialize::Token::StartObject { .. }) => {
			#[allow(unused_mut)]
			let mut builder = crate::model::ChatSimpleTopicParty::builder();
			loop {
				match tokens.next().transpose()? {
					Some(aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
					Some(aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
						match key.to_unescaped()?.as_ref() {
							"party_id" => {
								builder = builder.set_party_id(
									aws_smithy_json::deserialize::token::expect_string_or_null(
										tokens.next(),
									)?
									.map(|s| s.to_unescaped().map(|u| u.into_owned()))
									.transpose()?,
								);
							}
							_ => aws_smithy_json::deserialize::token::skip_value(tokens)?,
						}
					}
					other => {
						return Err(aws_smithy_json::deserialize::Error::custom(format!(
							"expected object key or end object, found: {:?}",
							other
						)))
					}
				}
			}
			Ok(Some(builder.build()))
		}
		_ => Err(aws_smithy_json::deserialize::Error::custom(
			"expected start object or null",
		)),
	}
}

pub fn deser_structure_crate_model_chat_simple_topic_direct<'a, I>(
	tokens: &mut std::iter::Peekable<I>,
) -> Result<Option<crate::model::ChatSimpleTopicDirect>, aws_smithy_json::deserialize::Error>
where
	I: Iterator<
		Item = Result<aws_smithy_json::deserialize::Token<'a>, aws_smithy_json::deserialize::Error>,
	>,
{
	match tokens.next().transpose()? {
		Some(aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
		Some(aws_smithy_json::deserialize::Token::StartObject { .. }) => {
			#[allow(unused_mut)]
			let mut builder = crate::model::ChatSimpleTopicDirect::builder();
			loop {
				match tokens.next().transpose()? {
					Some(aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
					Some(aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
						match key.to_unescaped()?.as_ref() {
							"identity_a_id" => {
								builder = builder.set_identity_a_id(
									aws_smithy_json::deserialize::token::expect_string_or_null(
										tokens.next(),
									)?
									.map(|s| s.to_unescaped().map(|u| u.into_owned()))
									.transpose()?,
								);
							}
							"identity_b_id" => {
								builder = builder.set_identity_b_id(
									aws_smithy_json::deserialize::token::expect_string_or_null(
										tokens.next(),
									)?
									.map(|s| s.to_unescaped().map(|u| u.into_owned()))
									.transpose()?,
								);
							}
							_ => aws_smithy_json::deserialize::token::skip_value(tokens)?,
						}
					}
					other => {
						return Err(aws_smithy_json::deserialize::Error::custom(format!(
							"expected object key or end object, found: {:?}",
							other
						)))
					}
				}
			}
			Ok(Some(builder.build()))
		}
		_ => Err(aws_smithy_json::deserialize::Error::custom(
			"expected start object or null",
		)),
	}
}

pub fn deser_structure_crate_model_chat_identity_typing_status<'a, I>(
	tokens: &mut std::iter::Peekable<I>,
) -> Result<Option<crate::model::ChatIdentityTypingStatus>, aws_smithy_json::deserialize::Error>
where
	I: Iterator<
		Item = Result<aws_smithy_json::deserialize::Token<'a>, aws_smithy_json::deserialize::Error>,
	>,
{
	match tokens.next().transpose()? {
		Some(aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
		Some(aws_smithy_json::deserialize::Token::StartObject { .. }) => {
			#[allow(unused_mut)]
			let mut builder = crate::model::ChatIdentityTypingStatus::builder();
			loop {
				match tokens.next().transpose()? {
					Some(aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
					Some(aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
						match key.to_unescaped()?.as_ref() {
							"identity" => {
								builder = builder.set_identity(
									crate::json_deser::deser_structure_crate_model_identity_handle(
										tokens,
									)?,
								);
							}
							"status" => {
								builder = builder.set_status(
									crate::json_deser::deser_union_crate_model_chat_typing_status(
										tokens,
									)?,
								);
							}
							_ => aws_smithy_json::deserialize::token::skip_value(tokens)?,
						}
					}
					other => {
						return Err(aws_smithy_json::deserialize::Error::custom(format!(
							"expected object key or end object, found: {:?}",
							other
						)))
					}
				}
			}
			Ok(Some(builder.build()))
		}
		_ => Err(aws_smithy_json::deserialize::Error::custom(
			"expected start object or null",
		)),
	}
}

pub fn deser_structure_crate_model_identity_game_activity<'a, I>(
	tokens: &mut std::iter::Peekable<I>,
) -> Result<Option<crate::model::IdentityGameActivity>, aws_smithy_json::deserialize::Error>
where
	I: Iterator<
		Item = Result<aws_smithy_json::deserialize::Token<'a>, aws_smithy_json::deserialize::Error>,
	>,
{
	match tokens.next().transpose()? {
		Some(aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
		Some(aws_smithy_json::deserialize::Token::StartObject { .. }) => {
			#[allow(unused_mut)]
			let mut builder = crate::model::IdentityGameActivity::builder();
			loop {
				match tokens.next().transpose()? {
					Some(aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
					Some(aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
						match key.to_unescaped()?.as_ref() {
							"game" => {
								builder = builder.set_game(
									crate::json_deser::deser_structure_crate_model_game_handle(
										tokens,
									)?,
								);
							}
							"message" => {
								builder = builder.set_message(
									aws_smithy_json::deserialize::token::expect_string_or_null(
										tokens.next(),
									)?
									.map(|s| s.to_unescaped().map(|u| u.into_owned()))
									.transpose()?,
								);
							}
							"public_metadata" => {
								builder = builder.set_public_metadata(Some(
									aws_smithy_json::deserialize::token::expect_document(tokens)?,
								));
							}
							"mutual_metadata" => {
								builder = builder.set_mutual_metadata(Some(
									aws_smithy_json::deserialize::token::expect_document(tokens)?,
								));
							}
							_ => aws_smithy_json::deserialize::token::skip_value(tokens)?,
						}
					}
					other => {
						return Err(aws_smithy_json::deserialize::Error::custom(format!(
							"expected object key or end object, found: {:?}",
							other
						)))
					}
				}
			}
			Ok(Some(builder.build()))
		}
		_ => Err(aws_smithy_json::deserialize::Error::custom(
			"expected start object or null",
		)),
	}
}

pub fn deser_union_crate_model_party_activity<'a, I>(
	tokens: &mut std::iter::Peekable<I>,
) -> Result<Option<crate::model::PartyActivity>, aws_smithy_json::deserialize::Error>
where
	I: Iterator<
		Item = Result<aws_smithy_json::deserialize::Token<'a>, aws_smithy_json::deserialize::Error>,
	>,
{
	let mut variant = None;
	match tokens.next().transpose()? {
		Some(aws_smithy_json::deserialize::Token::ValueNull { .. }) => return Ok(None),
		Some(aws_smithy_json::deserialize::Token::StartObject { .. }) => loop {
			match tokens.next().transpose()? {
				Some(aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
				Some(aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
					if variant.is_some() {
						return Err(aws_smithy_json::deserialize::Error::custom(
							"encountered mixed variants in union",
						));
					}
					variant = match key.to_unescaped()?.as_ref() {
                            "idle" => {
                                Some(crate::model::PartyActivity::Idle(
                                    crate::json_deser::deser_structure_crate_model_party_activity_idle(tokens)?
                                    .ok_or_else(|| aws_smithy_json::deserialize::Error::custom("value for 'idle' cannot be null"))?
                                ))
                            }
                            "matchmaker_finding_lobby" => {
                                Some(crate::model::PartyActivity::MatchmakerFindingLobby(
                                    crate::json_deser::deser_structure_crate_model_party_activity_matchmaker_finding_lobby(tokens)?
                                    .ok_or_else(|| aws_smithy_json::deserialize::Error::custom("value for 'matchmaker_finding_lobby' cannot be null"))?
                                ))
                            }
                            "matchmaker_lobby" => {
                                Some(crate::model::PartyActivity::MatchmakerLobby(
                                    crate::json_deser::deser_structure_crate_model_party_activity_matchmaker_lobby(tokens)?
                                    .ok_or_else(|| aws_smithy_json::deserialize::Error::custom("value for 'matchmaker_lobby' cannot be null"))?
                                ))
                            }
                            _ => {
                                                                      aws_smithy_json::deserialize::token::skip_value(tokens)?;
                                                                      Some(crate::model::PartyActivity::Unknown)
                                                                    }
                        };
				}
				other => {
					return Err(aws_smithy_json::deserialize::Error::custom(format!(
						"expected object key or end object, found: {:?}",
						other
					)))
				}
			}
		},
		_ => {
			return Err(aws_smithy_json::deserialize::Error::custom(
				"expected start object or null",
			))
		}
	}
	Ok(variant)
}

pub fn deser_structure_crate_model_party_external_links<'a, I>(
	tokens: &mut std::iter::Peekable<I>,
) -> Result<Option<crate::model::PartyExternalLinks>, aws_smithy_json::deserialize::Error>
where
	I: Iterator<
		Item = Result<aws_smithy_json::deserialize::Token<'a>, aws_smithy_json::deserialize::Error>,
	>,
{
	match tokens.next().transpose()? {
		Some(aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
		Some(aws_smithy_json::deserialize::Token::StartObject { .. }) => {
			#[allow(unused_mut)]
			let mut builder = crate::model::PartyExternalLinks::builder();
			loop {
				match tokens.next().transpose()? {
					Some(aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
					Some(aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
						match key.to_unescaped()?.as_ref() {
							"chat" => {
								builder = builder.set_chat(
									aws_smithy_json::deserialize::token::expect_string_or_null(
										tokens.next(),
									)?
									.map(|s| s.to_unescaped().map(|u| u.into_owned()))
									.transpose()?,
								);
							}
							_ => aws_smithy_json::deserialize::token::skip_value(tokens)?,
						}
					}
					other => {
						return Err(aws_smithy_json::deserialize::Error::custom(format!(
							"expected object key or end object, found: {:?}",
							other
						)))
					}
				}
			}
			Ok(Some(builder.build()))
		}
		_ => Err(aws_smithy_json::deserialize::Error::custom(
			"expected start object or null",
		)),
	}
}

pub fn deser_union_crate_model_chat_message_body<'a, I>(
	tokens: &mut std::iter::Peekable<I>,
) -> Result<Option<crate::model::ChatMessageBody>, aws_smithy_json::deserialize::Error>
where
	I: Iterator<
		Item = Result<aws_smithy_json::deserialize::Token<'a>, aws_smithy_json::deserialize::Error>,
	>,
{
	let mut variant = None;
	match tokens.next().transpose()? {
		Some(aws_smithy_json::deserialize::Token::ValueNull { .. }) => return Ok(None),
		Some(aws_smithy_json::deserialize::Token::StartObject { .. }) => loop {
			match tokens.next().transpose()? {
				Some(aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
				Some(aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
					if variant.is_some() {
						return Err(aws_smithy_json::deserialize::Error::custom(
							"encountered mixed variants in union",
						));
					}
					variant = match key.to_unescaped()?.as_ref() {
                            "text" => {
                                Some(crate::model::ChatMessageBody::Text(
                                    crate::json_deser::deser_structure_crate_model_chat_message_body_text(tokens)?
                                    .ok_or_else(|| aws_smithy_json::deserialize::Error::custom("value for 'text' cannot be null"))?
                                ))
                            }
                            "chat_create" => {
                                Some(crate::model::ChatMessageBody::ChatCreate(
                                    crate::json_deser::deser_structure_crate_model_chat_message_body_chat_create(tokens)?
                                    .ok_or_else(|| aws_smithy_json::deserialize::Error::custom("value for 'chat_create' cannot be null"))?
                                ))
                            }
                            "identity_follow" => {
                                Some(crate::model::ChatMessageBody::IdentityFollow(
                                    crate::json_deser::deser_structure_crate_model_chat_message_body_identity_follow(tokens)?
                                    .ok_or_else(|| aws_smithy_json::deserialize::Error::custom("value for 'identity_follow' cannot be null"))?
                                ))
                            }
                            "group_join" => {
                                Some(crate::model::ChatMessageBody::GroupJoin(
                                    crate::json_deser::deser_structure_crate_model_chat_message_body_group_join(tokens)?
                                    .ok_or_else(|| aws_smithy_json::deserialize::Error::custom("value for 'group_join' cannot be null"))?
                                ))
                            }
                            "group_leave" => {
                                Some(crate::model::ChatMessageBody::GroupLeave(
                                    crate::json_deser::deser_structure_crate_model_chat_message_body_group_leave(tokens)?
                                    .ok_or_else(|| aws_smithy_json::deserialize::Error::custom("value for 'group_leave' cannot be null"))?
                                ))
                            }
                            "party_invite" => {
                                Some(crate::model::ChatMessageBody::PartyInvite(
                                    crate::json_deser::deser_structure_crate_model_chat_message_body_party_invite(tokens)?
                                    .ok_or_else(|| aws_smithy_json::deserialize::Error::custom("value for 'party_invite' cannot be null"))?
                                ))
                            }
                            "party_join_request" => {
                                Some(crate::model::ChatMessageBody::PartyJoinRequest(
                                    crate::json_deser::deser_structure_crate_model_chat_message_body_party_join_request(tokens)?
                                    .ok_or_else(|| aws_smithy_json::deserialize::Error::custom("value for 'party_join_request' cannot be null"))?
                                ))
                            }
                            "party_join" => {
                                Some(crate::model::ChatMessageBody::PartyJoin(
                                    crate::json_deser::deser_structure_crate_model_chat_message_body_party_join(tokens)?
                                    .ok_or_else(|| aws_smithy_json::deserialize::Error::custom("value for 'party_join' cannot be null"))?
                                ))
                            }
                            "party_leave" => {
                                Some(crate::model::ChatMessageBody::PartyLeave(
                                    crate::json_deser::deser_structure_crate_model_chat_message_body_party_leave(tokens)?
                                    .ok_or_else(|| aws_smithy_json::deserialize::Error::custom("value for 'party_leave' cannot be null"))?
                                ))
                            }
                            "party_activity_change" => {
                                Some(crate::model::ChatMessageBody::PartyActivityChange(
                                    crate::json_deser::deser_structure_crate_model_chat_message_body_party_activity_change(tokens)?
                                    .ok_or_else(|| aws_smithy_json::deserialize::Error::custom("value for 'party_activity_change' cannot be null"))?
                                ))
                            }
                            _ => {
                                                                      aws_smithy_json::deserialize::token::skip_value(tokens)?;
                                                                      Some(crate::model::ChatMessageBody::Unknown)
                                                                    }
                        };
				}
				other => {
					return Err(aws_smithy_json::deserialize::Error::custom(format!(
						"expected object key or end object, found: {:?}",
						other
					)))
				}
			}
		},
		_ => {
			return Err(aws_smithy_json::deserialize::Error::custom(
				"expected start object or null",
			))
		}
	}
	Ok(variant)
}

pub fn deser_union_crate_model_chat_typing_status<'a, I>(
	tokens: &mut std::iter::Peekable<I>,
) -> Result<Option<crate::model::ChatTypingStatus>, aws_smithy_json::deserialize::Error>
where
	I: Iterator<
		Item = Result<aws_smithy_json::deserialize::Token<'a>, aws_smithy_json::deserialize::Error>,
	>,
{
	let mut variant = None;
	match tokens.next().transpose()? {
		Some(aws_smithy_json::deserialize::Token::ValueNull { .. }) => return Ok(None),
		Some(aws_smithy_json::deserialize::Token::StartObject { .. }) => loop {
			match tokens.next().transpose()? {
				Some(aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
				Some(aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
					if variant.is_some() {
						return Err(aws_smithy_json::deserialize::Error::custom(
							"encountered mixed variants in union",
						));
					}
					variant = match key.to_unescaped()?.as_ref() {
						"idle" => Some(crate::model::ChatTypingStatus::Idle(
							crate::json_deser::deser_structure_crate_model_unit(tokens)?
								.ok_or_else(|| {
									aws_smithy_json::deserialize::Error::custom(
										"value for 'idle' cannot be null",
									)
								})?,
						)),
						"typing" => Some(crate::model::ChatTypingStatus::Typing(
							crate::json_deser::deser_structure_crate_model_unit(tokens)?
								.ok_or_else(|| {
									aws_smithy_json::deserialize::Error::custom(
										"value for 'typing' cannot be null",
									)
								})?,
						)),
						_ => {
							aws_smithy_json::deserialize::token::skip_value(tokens)?;
							Some(crate::model::ChatTypingStatus::Unknown)
						}
					};
				}
				other => {
					return Err(aws_smithy_json::deserialize::Error::custom(format!(
						"expected object key or end object, found: {:?}",
						other
					)))
				}
			}
		},
		_ => {
			return Err(aws_smithy_json::deserialize::Error::custom(
				"expected start object or null",
			))
		}
	}
	Ok(variant)
}

pub fn deser_structure_crate_model_game_handle<'a, I>(
	tokens: &mut std::iter::Peekable<I>,
) -> Result<Option<crate::model::GameHandle>, aws_smithy_json::deserialize::Error>
where
	I: Iterator<
		Item = Result<aws_smithy_json::deserialize::Token<'a>, aws_smithy_json::deserialize::Error>,
	>,
{
	match tokens.next().transpose()? {
		Some(aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
		Some(aws_smithy_json::deserialize::Token::StartObject { .. }) => {
			#[allow(unused_mut)]
			let mut builder = crate::model::GameHandle::builder();
			loop {
				match tokens.next().transpose()? {
					Some(aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
					Some(aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
						match key.to_unescaped()?.as_ref() {
							"game_id" => {
								builder = builder.set_game_id(
									aws_smithy_json::deserialize::token::expect_string_or_null(
										tokens.next(),
									)?
									.map(|s| s.to_unescaped().map(|u| u.into_owned()))
									.transpose()?,
								);
							}
							"name_id" => {
								builder = builder.set_name_id(
									aws_smithy_json::deserialize::token::expect_string_or_null(
										tokens.next(),
									)?
									.map(|s| s.to_unescaped().map(|u| u.into_owned()))
									.transpose()?,
								);
							}
							"display_name" => {
								builder = builder.set_display_name(
									aws_smithy_json::deserialize::token::expect_string_or_null(
										tokens.next(),
									)?
									.map(|s| s.to_unescaped().map(|u| u.into_owned()))
									.transpose()?,
								);
							}
							"logo_url" => {
								builder = builder.set_logo_url(
									aws_smithy_json::deserialize::token::expect_string_or_null(
										tokens.next(),
									)?
									.map(|s| s.to_unescaped().map(|u| u.into_owned()))
									.transpose()?,
								);
							}
							"banner_url" => {
								builder = builder.set_banner_url(
									aws_smithy_json::deserialize::token::expect_string_or_null(
										tokens.next(),
									)?
									.map(|s| s.to_unescaped().map(|u| u.into_owned()))
									.transpose()?,
								);
							}
							_ => aws_smithy_json::deserialize::token::skip_value(tokens)?,
						}
					}
					other => {
						return Err(aws_smithy_json::deserialize::Error::custom(format!(
							"expected object key or end object, found: {:?}",
							other
						)))
					}
				}
			}
			Ok(Some(builder.build()))
		}
		_ => Err(aws_smithy_json::deserialize::Error::custom(
			"expected start object or null",
		)),
	}
}

pub fn deser_structure_crate_model_party_activity_idle<'a, I>(
	tokens: &mut std::iter::Peekable<I>,
) -> Result<Option<crate::model::PartyActivityIdle>, aws_smithy_json::deserialize::Error>
where
	I: Iterator<
		Item = Result<aws_smithy_json::deserialize::Token<'a>, aws_smithy_json::deserialize::Error>,
	>,
{
	match tokens.next().transpose()? {
		Some(aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
		Some(aws_smithy_json::deserialize::Token::StartObject { .. }) => {
			#[allow(unused_mut)]
			let mut builder = crate::model::PartyActivityIdle::builder();
			aws_smithy_json::deserialize::token::skip_to_end(tokens)?;
			Ok(Some(builder.build()))
		}
		_ => Err(aws_smithy_json::deserialize::Error::custom(
			"expected start object or null",
		)),
	}
}

pub fn deser_structure_crate_model_party_activity_matchmaker_finding_lobby<'a, I>(
	tokens: &mut std::iter::Peekable<I>,
) -> Result<
	Option<crate::model::PartyActivityMatchmakerFindingLobby>,
	aws_smithy_json::deserialize::Error,
>
where
	I: Iterator<
		Item = Result<aws_smithy_json::deserialize::Token<'a>, aws_smithy_json::deserialize::Error>,
	>,
{
	match tokens.next().transpose()? {
		Some(aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
		Some(aws_smithy_json::deserialize::Token::StartObject { .. }) => {
			#[allow(unused_mut)]
			let mut builder = crate::model::PartyActivityMatchmakerFindingLobby::builder();
			loop {
				match tokens.next().transpose()? {
					Some(aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
					Some(aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
						match key.to_unescaped()?.as_ref() {
							"game" => {
								builder = builder.set_game(
									crate::json_deser::deser_structure_crate_model_game_handle(
										tokens,
									)?,
								);
							}
							_ => aws_smithy_json::deserialize::token::skip_value(tokens)?,
						}
					}
					other => {
						return Err(aws_smithy_json::deserialize::Error::custom(format!(
							"expected object key or end object, found: {:?}",
							other
						)))
					}
				}
			}
			Ok(Some(builder.build()))
		}
		_ => Err(aws_smithy_json::deserialize::Error::custom(
			"expected start object or null",
		)),
	}
}

pub fn deser_structure_crate_model_party_activity_matchmaker_lobby<'a, I>(
	tokens: &mut std::iter::Peekable<I>,
) -> Result<Option<crate::model::PartyActivityMatchmakerLobby>, aws_smithy_json::deserialize::Error>
where
	I: Iterator<
		Item = Result<aws_smithy_json::deserialize::Token<'a>, aws_smithy_json::deserialize::Error>,
	>,
{
	match tokens.next().transpose()? {
		Some(aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
		Some(aws_smithy_json::deserialize::Token::StartObject { .. }) => {
			#[allow(unused_mut)]
			let mut builder = crate::model::PartyActivityMatchmakerLobby::builder();
			loop {
				match tokens.next().transpose()? {
					Some(aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
					Some(aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
						match key.to_unescaped()?.as_ref() {
							"lobby" => {
								builder = builder.set_lobby(
                                    crate::json_deser::deser_structure_crate_model_party_matchmaker_lobby(tokens)?
                                );
							}
							"game" => {
								builder = builder.set_game(
									crate::json_deser::deser_structure_crate_model_game_handle(
										tokens,
									)?,
								);
							}
							_ => aws_smithy_json::deserialize::token::skip_value(tokens)?,
						}
					}
					other => {
						return Err(aws_smithy_json::deserialize::Error::custom(format!(
							"expected object key or end object, found: {:?}",
							other
						)))
					}
				}
			}
			Ok(Some(builder.build()))
		}
		_ => Err(aws_smithy_json::deserialize::Error::custom(
			"expected start object or null",
		)),
	}
}

pub fn deser_structure_crate_model_chat_message_body_text<'a, I>(
	tokens: &mut std::iter::Peekable<I>,
) -> Result<Option<crate::model::ChatMessageBodyText>, aws_smithy_json::deserialize::Error>
where
	I: Iterator<
		Item = Result<aws_smithy_json::deserialize::Token<'a>, aws_smithy_json::deserialize::Error>,
	>,
{
	match tokens.next().transpose()? {
		Some(aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
		Some(aws_smithy_json::deserialize::Token::StartObject { .. }) => {
			#[allow(unused_mut)]
			let mut builder = crate::model::ChatMessageBodyText::builder();
			loop {
				match tokens.next().transpose()? {
					Some(aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
					Some(aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
						match key.to_unescaped()?.as_ref() {
							"sender" => {
								builder = builder.set_sender(
									crate::json_deser::deser_structure_crate_model_identity_handle(
										tokens,
									)?,
								);
							}
							"body" => {
								builder = builder.set_body(
									aws_smithy_json::deserialize::token::expect_string_or_null(
										tokens.next(),
									)?
									.map(|s| s.to_unescaped().map(|u| u.into_owned()))
									.transpose()?,
								);
							}
							_ => aws_smithy_json::deserialize::token::skip_value(tokens)?,
						}
					}
					other => {
						return Err(aws_smithy_json::deserialize::Error::custom(format!(
							"expected object key or end object, found: {:?}",
							other
						)))
					}
				}
			}
			Ok(Some(builder.build()))
		}
		_ => Err(aws_smithy_json::deserialize::Error::custom(
			"expected start object or null",
		)),
	}
}

pub fn deser_structure_crate_model_chat_message_body_chat_create<'a, I>(
	tokens: &mut std::iter::Peekable<I>,
) -> Result<Option<crate::model::ChatMessageBodyChatCreate>, aws_smithy_json::deserialize::Error>
where
	I: Iterator<
		Item = Result<aws_smithy_json::deserialize::Token<'a>, aws_smithy_json::deserialize::Error>,
	>,
{
	match tokens.next().transpose()? {
		Some(aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
		Some(aws_smithy_json::deserialize::Token::StartObject { .. }) => {
			#[allow(unused_mut)]
			let mut builder = crate::model::ChatMessageBodyChatCreate::builder();
			aws_smithy_json::deserialize::token::skip_to_end(tokens)?;
			Ok(Some(builder.build()))
		}
		_ => Err(aws_smithy_json::deserialize::Error::custom(
			"expected start object or null",
		)),
	}
}

pub fn deser_structure_crate_model_chat_message_body_identity_follow<'a, I>(
	tokens: &mut std::iter::Peekable<I>,
) -> Result<Option<crate::model::ChatMessageBodyIdentityFollow>, aws_smithy_json::deserialize::Error>
where
	I: Iterator<
		Item = Result<aws_smithy_json::deserialize::Token<'a>, aws_smithy_json::deserialize::Error>,
	>,
{
	match tokens.next().transpose()? {
		Some(aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
		Some(aws_smithy_json::deserialize::Token::StartObject { .. }) => {
			#[allow(unused_mut)]
			let mut builder = crate::model::ChatMessageBodyIdentityFollow::builder();
			aws_smithy_json::deserialize::token::skip_to_end(tokens)?;
			Ok(Some(builder.build()))
		}
		_ => Err(aws_smithy_json::deserialize::Error::custom(
			"expected start object or null",
		)),
	}
}

pub fn deser_structure_crate_model_chat_message_body_group_join<'a, I>(
	tokens: &mut std::iter::Peekable<I>,
) -> Result<Option<crate::model::ChatMessageBodyGroupJoin>, aws_smithy_json::deserialize::Error>
where
	I: Iterator<
		Item = Result<aws_smithy_json::deserialize::Token<'a>, aws_smithy_json::deserialize::Error>,
	>,
{
	match tokens.next().transpose()? {
		Some(aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
		Some(aws_smithy_json::deserialize::Token::StartObject { .. }) => {
			#[allow(unused_mut)]
			let mut builder = crate::model::ChatMessageBodyGroupJoin::builder();
			loop {
				match tokens.next().transpose()? {
					Some(aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
					Some(aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
						match key.to_unescaped()?.as_ref() {
							"identity" => {
								builder = builder.set_identity(
									crate::json_deser::deser_structure_crate_model_identity_handle(
										tokens,
									)?,
								);
							}
							_ => aws_smithy_json::deserialize::token::skip_value(tokens)?,
						}
					}
					other => {
						return Err(aws_smithy_json::deserialize::Error::custom(format!(
							"expected object key or end object, found: {:?}",
							other
						)))
					}
				}
			}
			Ok(Some(builder.build()))
		}
		_ => Err(aws_smithy_json::deserialize::Error::custom(
			"expected start object or null",
		)),
	}
}

pub fn deser_structure_crate_model_chat_message_body_group_leave<'a, I>(
	tokens: &mut std::iter::Peekable<I>,
) -> Result<Option<crate::model::ChatMessageBodyGroupLeave>, aws_smithy_json::deserialize::Error>
where
	I: Iterator<
		Item = Result<aws_smithy_json::deserialize::Token<'a>, aws_smithy_json::deserialize::Error>,
	>,
{
	match tokens.next().transpose()? {
		Some(aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
		Some(aws_smithy_json::deserialize::Token::StartObject { .. }) => {
			#[allow(unused_mut)]
			let mut builder = crate::model::ChatMessageBodyGroupLeave::builder();
			loop {
				match tokens.next().transpose()? {
					Some(aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
					Some(aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
						match key.to_unescaped()?.as_ref() {
							"identity" => {
								builder = builder.set_identity(
									crate::json_deser::deser_structure_crate_model_identity_handle(
										tokens,
									)?,
								);
							}
							_ => aws_smithy_json::deserialize::token::skip_value(tokens)?,
						}
					}
					other => {
						return Err(aws_smithy_json::deserialize::Error::custom(format!(
							"expected object key or end object, found: {:?}",
							other
						)))
					}
				}
			}
			Ok(Some(builder.build()))
		}
		_ => Err(aws_smithy_json::deserialize::Error::custom(
			"expected start object or null",
		)),
	}
}

pub fn deser_structure_crate_model_chat_message_body_party_invite<'a, I>(
	tokens: &mut std::iter::Peekable<I>,
) -> Result<Option<crate::model::ChatMessageBodyPartyInvite>, aws_smithy_json::deserialize::Error>
where
	I: Iterator<
		Item = Result<aws_smithy_json::deserialize::Token<'a>, aws_smithy_json::deserialize::Error>,
	>,
{
	match tokens.next().transpose()? {
		Some(aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
		Some(aws_smithy_json::deserialize::Token::StartObject { .. }) => {
			#[allow(unused_mut)]
			let mut builder = crate::model::ChatMessageBodyPartyInvite::builder();
			loop {
				match tokens.next().transpose()? {
					Some(aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
					Some(aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
						match key.to_unescaped()?.as_ref() {
							"sender" => {
								builder = builder.set_sender(
									crate::json_deser::deser_structure_crate_model_identity_handle(
										tokens,
									)?,
								);
							}
							"party" => {
								builder = builder.set_party(
									crate::json_deser::deser_structure_crate_model_party_handle(
										tokens,
									)?,
								);
							}
							"invite_token" => {
								builder = builder.set_invite_token(
									aws_smithy_json::deserialize::token::expect_string_or_null(
										tokens.next(),
									)?
									.map(|s| s.to_unescaped().map(|u| u.into_owned()))
									.transpose()?,
								);
							}
							_ => aws_smithy_json::deserialize::token::skip_value(tokens)?,
						}
					}
					other => {
						return Err(aws_smithy_json::deserialize::Error::custom(format!(
							"expected object key or end object, found: {:?}",
							other
						)))
					}
				}
			}
			Ok(Some(builder.build()))
		}
		_ => Err(aws_smithy_json::deserialize::Error::custom(
			"expected start object or null",
		)),
	}
}

pub fn deser_structure_crate_model_chat_message_body_party_join_request<'a, I>(
	tokens: &mut std::iter::Peekable<I>,
) -> Result<
	Option<crate::model::ChatMessageBodyPartyJoinRequest>,
	aws_smithy_json::deserialize::Error,
>
where
	I: Iterator<
		Item = Result<aws_smithy_json::deserialize::Token<'a>, aws_smithy_json::deserialize::Error>,
	>,
{
	match tokens.next().transpose()? {
		Some(aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
		Some(aws_smithy_json::deserialize::Token::StartObject { .. }) => {
			#[allow(unused_mut)]
			let mut builder = crate::model::ChatMessageBodyPartyJoinRequest::builder();
			loop {
				match tokens.next().transpose()? {
					Some(aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
					Some(aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
						match key.to_unescaped()?.as_ref() {
							"sender" => {
								builder = builder.set_sender(
									crate::json_deser::deser_structure_crate_model_identity_handle(
										tokens,
									)?,
								);
							}
							_ => aws_smithy_json::deserialize::token::skip_value(tokens)?,
						}
					}
					other => {
						return Err(aws_smithy_json::deserialize::Error::custom(format!(
							"expected object key or end object, found: {:?}",
							other
						)))
					}
				}
			}
			Ok(Some(builder.build()))
		}
		_ => Err(aws_smithy_json::deserialize::Error::custom(
			"expected start object or null",
		)),
	}
}

pub fn deser_structure_crate_model_chat_message_body_party_join<'a, I>(
	tokens: &mut std::iter::Peekable<I>,
) -> Result<Option<crate::model::ChatMessageBodyPartyJoin>, aws_smithy_json::deserialize::Error>
where
	I: Iterator<
		Item = Result<aws_smithy_json::deserialize::Token<'a>, aws_smithy_json::deserialize::Error>,
	>,
{
	match tokens.next().transpose()? {
		Some(aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
		Some(aws_smithy_json::deserialize::Token::StartObject { .. }) => {
			#[allow(unused_mut)]
			let mut builder = crate::model::ChatMessageBodyPartyJoin::builder();
			loop {
				match tokens.next().transpose()? {
					Some(aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
					Some(aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
						match key.to_unescaped()?.as_ref() {
							"identity" => {
								builder = builder.set_identity(
									crate::json_deser::deser_structure_crate_model_identity_handle(
										tokens,
									)?,
								);
							}
							_ => aws_smithy_json::deserialize::token::skip_value(tokens)?,
						}
					}
					other => {
						return Err(aws_smithy_json::deserialize::Error::custom(format!(
							"expected object key or end object, found: {:?}",
							other
						)))
					}
				}
			}
			Ok(Some(builder.build()))
		}
		_ => Err(aws_smithy_json::deserialize::Error::custom(
			"expected start object or null",
		)),
	}
}

pub fn deser_structure_crate_model_chat_message_body_party_leave<'a, I>(
	tokens: &mut std::iter::Peekable<I>,
) -> Result<Option<crate::model::ChatMessageBodyPartyLeave>, aws_smithy_json::deserialize::Error>
where
	I: Iterator<
		Item = Result<aws_smithy_json::deserialize::Token<'a>, aws_smithy_json::deserialize::Error>,
	>,
{
	match tokens.next().transpose()? {
		Some(aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
		Some(aws_smithy_json::deserialize::Token::StartObject { .. }) => {
			#[allow(unused_mut)]
			let mut builder = crate::model::ChatMessageBodyPartyLeave::builder();
			loop {
				match tokens.next().transpose()? {
					Some(aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
					Some(aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
						match key.to_unescaped()?.as_ref() {
							"identity" => {
								builder = builder.set_identity(
									crate::json_deser::deser_structure_crate_model_identity_handle(
										tokens,
									)?,
								);
							}
							_ => aws_smithy_json::deserialize::token::skip_value(tokens)?,
						}
					}
					other => {
						return Err(aws_smithy_json::deserialize::Error::custom(format!(
							"expected object key or end object, found: {:?}",
							other
						)))
					}
				}
			}
			Ok(Some(builder.build()))
		}
		_ => Err(aws_smithy_json::deserialize::Error::custom(
			"expected start object or null",
		)),
	}
}

pub fn deser_structure_crate_model_chat_message_body_party_activity_change<'a, I>(
	tokens: &mut std::iter::Peekable<I>,
) -> Result<
	Option<crate::model::ChatMessageBodyPartyActivityChange>,
	aws_smithy_json::deserialize::Error,
>
where
	I: Iterator<
		Item = Result<aws_smithy_json::deserialize::Token<'a>, aws_smithy_json::deserialize::Error>,
	>,
{
	match tokens.next().transpose()? {
		Some(aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
		Some(aws_smithy_json::deserialize::Token::StartObject { .. }) => {
			#[allow(unused_mut)]
			let mut builder = crate::model::ChatMessageBodyPartyActivityChange::builder();
			aws_smithy_json::deserialize::token::skip_to_end(tokens)?;
			Ok(Some(builder.build()))
		}
		_ => Err(aws_smithy_json::deserialize::Error::custom(
			"expected start object or null",
		)),
	}
}

pub fn deser_structure_crate_model_unit<'a, I>(
	tokens: &mut std::iter::Peekable<I>,
) -> Result<Option<crate::model::Unit>, aws_smithy_json::deserialize::Error>
where
	I: Iterator<
		Item = Result<aws_smithy_json::deserialize::Token<'a>, aws_smithy_json::deserialize::Error>,
	>,
{
	match tokens.next().transpose()? {
		Some(aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
		Some(aws_smithy_json::deserialize::Token::StartObject { .. }) => {
			#[allow(unused_mut)]
			let mut builder = crate::model::Unit::builder();
			aws_smithy_json::deserialize::token::skip_to_end(tokens)?;
			Ok(Some(builder.build()))
		}
		_ => Err(aws_smithy_json::deserialize::Error::custom(
			"expected start object or null",
		)),
	}
}

pub fn deser_structure_crate_model_party_matchmaker_lobby<'a, I>(
	tokens: &mut std::iter::Peekable<I>,
) -> Result<Option<crate::model::PartyMatchmakerLobby>, aws_smithy_json::deserialize::Error>
where
	I: Iterator<
		Item = Result<aws_smithy_json::deserialize::Token<'a>, aws_smithy_json::deserialize::Error>,
	>,
{
	match tokens.next().transpose()? {
		Some(aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
		Some(aws_smithy_json::deserialize::Token::StartObject { .. }) => {
			#[allow(unused_mut)]
			let mut builder = crate::model::PartyMatchmakerLobby::builder();
			loop {
				match tokens.next().transpose()? {
					Some(aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
					Some(aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
						match key.to_unescaped()?.as_ref() {
							"lobby_id" => {
								builder = builder.set_lobby_id(
									aws_smithy_json::deserialize::token::expect_string_or_null(
										tokens.next(),
									)?
									.map(|s| s.to_unescaped().map(|u| u.into_owned()))
									.transpose()?,
								);
							}
							_ => aws_smithy_json::deserialize::token::skip_value(tokens)?,
						}
					}
					other => {
						return Err(aws_smithy_json::deserialize::Error::custom(format!(
							"expected object key or end object, found: {:?}",
							other
						)))
					}
				}
			}
			Ok(Some(builder.build()))
		}
		_ => Err(aws_smithy_json::deserialize::Error::custom(
			"expected start object or null",
		)),
	}
}