-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Labels
CodeGenIssues that relate to code generationIssues that relate to code generationfeature-requestThis issue requires a new behavior in the product in order be resolved.This issue requires a new behavior in the product in order be resolved.
Description
Currently, the send_message API is defined as follows:
pub async fn send_message(
&self,
queue_message: RequestContent<QueueMessage, XmlFormat>,
options: Option<QueueClientSendMessageOptions<'_>>,
) -> Result<Response<SentMessage, XmlFormat>> {
let response = self.client.send_message(queue_message, options).await?;
Self::extract_first_message(response, |list: &ListOfSentMessage| {
list.items.clone().unwrap_or_default()
})
.await
}This is because the underlying generated function is defined as:
pub async fn send_message(
&self,
queue_message: RequestContent<QueueMessage, XmlFormat>,
options: Option<QueueClientSendMessageInternalOptions<'_>>,
) -> Result<Response<ListOfSentMessage, XmlFormat>> {So the feature request is whether there is anyway we can define something, similar to alternateType, but we would want to be able to define in this case:
- Turn
send_messagereturn type fromListOfSentMessagetoSentMessage - We can define the conversion function in handwritten code to go from
ListOfSentMessage->SentMessage
We just want to be able to define this sort of behavior without having to maintain the handwritten layer just for this functionality.
For completeness, this is the current implementation of extract_first_message() which is what we currently use to do the repacking to the desired return type:
async fn extract_first_sent_message(
response: Response<ListOfSentMessage, XmlFormat>,
) -> Result<Response<SentMessage, XmlFormat>> {
let status = response.status();
let headers = response.headers().clone();
let list = response.into_model()?;
let first = list
.items
.unwrap_or_default()
.into_iter()
.next()
.ok_or_else(|| {
azure_core::Error::with_message(
azure_core::error::ErrorKind::DataConversion,
"No messages found in the response.",
)
})?;
let xml_body = xml::to_xml(&first)?;
Ok(RawResponse::from_bytes(status, headers, xml_body).into())
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
CodeGenIssues that relate to code generationIssues that relate to code generationfeature-requestThis issue requires a new behavior in the product in order be resolved.This issue requires a new behavior in the product in order be resolved.
Type
Projects
Status
Untriaged