|
| 1 | +use azure_core::headers::CommonStorageResponseHeaders; |
| 2 | +use azure_core::prelude::ContentLength; |
| 3 | +use azure_core::prelude::IfMatchCondition; |
| 4 | +use std::convert::TryInto; |
| 5 | + |
| 6 | +use azure_core::{Request as HttpRequest, Response as HttpResponse}; |
| 7 | + |
| 8 | +#[derive(Debug, Clone, Default)] |
| 9 | +pub struct FileDeleteOptions<'a> { |
| 10 | + if_match_condition: Option<IfMatchCondition<'a>>, |
| 11 | +} |
| 12 | + |
| 13 | +impl<'a> FileDeleteOptions<'a> { |
| 14 | + pub fn new() -> Self { |
| 15 | + Self { |
| 16 | + if_match_condition: None, |
| 17 | + } |
| 18 | + } |
| 19 | + |
| 20 | + setters! { |
| 21 | + if_match_condition: IfMatchCondition<'a> => Some(if_match_condition), |
| 22 | + } |
| 23 | + |
| 24 | + pub(crate) fn decorate_request(&self, req: &mut HttpRequest) -> Result<(), crate::Error> { |
| 25 | + azure_core::headers::add_optional_header2(&self.if_match_condition, req)?; |
| 26 | + azure_core::headers::add_mandatory_header2(&ContentLength::new(0), req)?; // Length is required for creating files |
| 27 | + |
| 28 | + Ok(()) |
| 29 | + } |
| 30 | +} |
| 31 | + |
| 32 | +#[derive(Debug, Clone)] |
| 33 | +pub struct FileDeleteResponse { |
| 34 | + pub common_storage_response_headers: CommonStorageResponseHeaders, |
| 35 | +} |
| 36 | + |
| 37 | +impl FileDeleteResponse { |
| 38 | + pub async fn try_from(response: HttpResponse) -> Result<Self, crate::Error> { |
| 39 | + let (_status_code, headers, _pinned_stream) = response.deconstruct(); |
| 40 | + |
| 41 | + let common_storage_response_headers = (&headers).try_into()?; |
| 42 | + |
| 43 | + Ok(Self { |
| 44 | + common_storage_response_headers, |
| 45 | + }) |
| 46 | + } |
| 47 | +} |
0 commit comments