use super::QueueClientGetPropertiesResult;
use azure_core::{
http::{
headers::{HeaderName, Headers},
NoFormat, Response,
},
Result,
};
use std::collections::HashMap;
const APPROXIMATE_MESSAGES_COUNT: HeaderName =
HeaderName::from_static("x-ms-approximate-messages-count");
const META: &str = "x-ms-meta-";
pub trait QueueClientGetPropertiesResultHeaders: private::Sealed {
fn approximate_messages_count(&self) -> Result<Option<i64>>;
fn metadata(&self) -> Result<HashMap<String, String>>;
}
impl QueueClientGetPropertiesResultHeaders for Response<QueueClientGetPropertiesResult, NoFormat> {
fn approximate_messages_count(&self) -> Result<Option<i64>> {
Headers::get_optional_as(self.headers(), &APPROXIMATE_MESSAGES_COUNT)
}
fn metadata(&self) -> Result<HashMap<String, String>> {
let mut values = HashMap::new();
for h in self.headers().iter() {
let name = h.0.as_str();
if name.len() > META.len() && name.starts_with(META) {
values.insert(name[META.len()..].to_owned(), h.1.as_str().to_owned());
}
}
Ok(values)
}
}
mod private {
use super::QueueClientGetPropertiesResult;
use azure_core::http::{NoFormat, Response};
pub trait Sealed {}
impl Sealed for Response<QueueClientGetPropertiesResult, NoFormat> {}
}