Skip to content

Commit 1f25a4e

Browse files
authored
Add NoFormat response type (#2690)
Tweaked a few of docs for the other format types.
1 parent 9ed9686 commit 1f25a4e

File tree

2 files changed

+18
-3
lines changed
  • sdk
    • core/azure_core/src/http
    • typespec/typespec_client_core/src/http

2 files changed

+18
-3
lines changed

sdk/core/azure_core/src/http/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ pub use response::{RawResponse, Response};
2121

2222
pub use typespec_client_core::http::response;
2323
pub use typespec_client_core::http::{
24-
new_http_client, AppendToUrlQuery, Context, Format, HttpClient, JsonFormat, Method, StatusCode,
25-
Url,
24+
new_http_client, AppendToUrlQuery, Context, Format, HttpClient, JsonFormat, Method, NoFormat,
25+
StatusCode, Url,
2626
};
2727

2828
#[cfg(feature = "xml")]

sdk/typespec/typespec_client_core/src/http/format.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ impl<D: DeserializeOwned> DeserializeWith<JsonFormat> for D {
3737
}
3838
}
3939

40-
/// The default format used for deserialization.
40+
/// A [`Format`] that deserializes response bodies using JSON.
41+
/// This is the default format used for deserialization.
4142
///
4243
/// This format supports deserializing response bodies to:
4344
/// * [`ResponseBody`] - The raw response body, without any deserialization.
@@ -48,6 +49,10 @@ pub struct JsonFormat;
4849
impl Format for JsonFormat {}
4950

5051
/// A [`Format`] that deserializes response bodies using XML.
52+
///
53+
/// This format supports deserializing response bodies to:
54+
/// * [`ResponseBody`] - The raw response body, without any deserialization.
55+
/// * Any value implementing [`serde::de::DeserializeOwned`] - Deserializes the response body to the specified type using XML deserialization.
5156
#[cfg(feature = "xml")]
5257
#[derive(Debug, Clone)]
5358
pub struct XmlFormat;
@@ -63,3 +68,13 @@ impl<D: DeserializeOwned> DeserializeWith<XmlFormat> for D {
6368
body.xml().await
6469
}
6570
}
71+
72+
/// A [`Format`] indicating that the response has no structured format.
73+
/// This includes responses that return raw data and that don't return a response body.
74+
///
75+
/// This format supports deserializing response bodies to:
76+
/// * [`ResponseBody`] - The raw response body, without any deserialization.
77+
#[derive(Debug, Clone)]
78+
pub struct NoFormat;
79+
80+
impl Format for NoFormat {}

0 commit comments

Comments
 (0)