in sdk/core/azure_core_amqp/src/messaging.rs [808:865]
fn from(properties: AmqpMessageProperties) -> AmqpList {
let mut list = vec![AmqpValue::Null; 13];
// Serialize the current value, if it exists. Otherwise serialize a null
list[0] = properties
.message_id
.map_or(AmqpValue::Null, AmqpValue::from);
list[1] = properties
.user_id
.map_or(AmqpValue::Null, AmqpValue::Binary);
list[2] = properties.to.map_or(AmqpValue::Null, AmqpValue::String);
list[3] = properties
.subject
.map_or(AmqpValue::Null, AmqpValue::String);
list[4] = properties
.reply_to
.map_or(AmqpValue::Null, AmqpValue::String);
list[5] = properties
.correlation_id
.map_or(AmqpValue::Null, AmqpValue::from);
list[6] = properties
.content_type
.map_or(AmqpValue::Null, AmqpValue::Symbol);
list[7] = properties
.content_encoding
.map_or(AmqpValue::Null, AmqpValue::Symbol);
list[8] = properties
.absolute_expiry_time
.map_or(AmqpValue::Null, AmqpValue::TimeStamp);
list[9] = properties
.creation_time
.map_or(AmqpValue::Null, AmqpValue::TimeStamp);
list[10] = properties
.group_id
.map_or(AmqpValue::Null, AmqpValue::String);
list[11] = properties
.group_sequence
.map_or(AmqpValue::Null, AmqpValue::UInt);
list[12] = properties
.reply_to_group_id
.map_or(AmqpValue::Null, AmqpValue::String);
// We will potentially have a set of trailing Null values in the list at this point,
// we don't ever want the trailing null values to appear in the list so we remove them.
// This behavior is described by the [AMQP spec, section 1.4](https://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-types-v1.0-os.html#section-composite-type-representation)
// "When the trailing elements of the list representation are null, they MAY be omitted".
let mut trailing_nulls = 0;
for val in list.iter().rev() {
if *val != AmqpValue::Null {
break;
}
trailing_nulls += 1;
}
list.truncate(list.len() - trailing_nulls);
AmqpList::from(list)
}