use azure_core::http::Url;
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct CosmosAccountEndpoint(Url);
impl CosmosAccountEndpoint {
pub fn url(&self) -> &Url {
&self.0
}
pub fn into_url(self) -> Url {
self.0
}
}
impl std::str::FromStr for CosmosAccountEndpoint {
type Err = azure_core::Error;
fn from_str(s: &str) -> Result<Self, Self::Err> {
let url: Url = s.parse().map_err(|e: url::ParseError| {
azure_core::Error::new(azure_core::error::ErrorKind::Other, e)
})?;
Ok(Self(url))
}
}
impl From<Url> for CosmosAccountEndpoint {
fn from(url: Url) -> Self {
Self(url)
}
}
impl std::fmt::Display for CosmosAccountEndpoint {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
self.0.fmt(f)
}
}