#[non_exhaustive]pub struct CosmosResponse { /* private fields */ }Expand description
Result of a Cosmos DB operation.
Contains the response body (as a ResponseBody of one or more
reference-counted byte slices), relevant headers, and comprehensive status
information for the operation.
§Schema-Agnostic Design
The driver returns response bodies as raw bytes via ResponseBody.
The higher-level SDK (e.g., azure_data_cosmos) handles deserialization into
typed structures. This allows the driver to be reused across different
serialization strategies.
§Example
let result = driver.execute_operation(/* ... */).await?;
let status = result.status();
println!("Status: {}", status);
println!("RU Charge: {}", result.headers().request_charge.unwrap_or_default().value());
if status.is_success() {
let body = result.into_body();
// Deserialize body...
}Implementations§
Source§impl CosmosResponse
impl CosmosResponse
Sourcepub fn body(&self) -> &ResponseBody
pub fn body(&self) -> &ResponseBody
Returns a reference to the typed response body.
Sourcepub fn into_body(self) -> ResponseBody
pub fn into_body(self) -> ResponseBody
Consumes the response and returns the body.
Sourcepub fn headers(&self) -> &CosmosResponseHeaders
pub fn headers(&self) -> &CosmosResponseHeaders
Returns a reference to the extracted headers.
Sourcepub fn status(&self) -> CosmosStatus
pub fn status(&self) -> CosmosStatus
Returns the operation status.
Sourcepub fn diagnostics(&self) -> Arc<DiagnosticsContext> ⓘ
pub fn diagnostics(&self) -> Arc<DiagnosticsContext> ⓘ
Returns a cloned Arc handle to the diagnostics captured for this operation.
Cloning the Arc is a cheap atomic increment, allowing the diagnostics
to be retained alongside the response data when the CosmosResponse is
consumed (for example, by into_body). For read-only
inspection, the returned handle derefs transparently to
DiagnosticsContext.
Sourcepub fn diagnostics_ref(&self) -> &Arc<DiagnosticsContext> ⓘ
pub fn diagnostics_ref(&self) -> &Arc<DiagnosticsContext> ⓘ
Returns a borrow of the diagnostics Arc without cloning it.
Trait Implementations§
Source§impl Clone for CosmosResponse
impl Clone for CosmosResponse
Source§fn clone(&self) -> CosmosResponse
fn clone(&self) -> CosmosResponse
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more