use azure_core::http::Url;
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct AccountEndpoint(Url);
impl AccountEndpoint {
pub fn url(&self) -> &Url {
&self.0
}
pub fn into_url(self) -> Url {
self.0
}
}
impl std::str::FromStr for AccountEndpoint {
type Err = crate::CosmosError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
let url: Url = s.parse().map_err(|e: url::ParseError| {
crate::DriverCosmosError::builder()
.with_status(crate::CosmosStatus::CLIENT_INVALID_ACCOUNT_ENDPOINT_URL)
.with_message("invalid account endpoint URL")
.with_arc_source(std::sync::Arc::new(e))
.build()
})?;
Ok(Self(url))
}
}
impl From<Url> for AccountEndpoint {
fn from(url: Url) -> Self {
Self(url)
}
}
impl std::fmt::Display for AccountEndpoint {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
self.0.fmt(f)
}
}