use crate::error::Error;
use url::Url;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Endpoint {
Frankfurt,
London,
NewYork,
LosAngeles,
Singapore,
Stockholm,
SaoPaulo,
Johannesburg,
Sydney,
Custom(String),
}
impl TryInto<Url> for Endpoint {
type Error = Error;
fn try_into(self) -> Result<Url, Error> {
match self {
Endpoint::Frankfurt => Ok(Url::parse("https://storage.bunnycdn.com")?),
Endpoint::London => Ok(Url::parse("https://uk.storage.bunnycdn.com")?),
Endpoint::NewYork => Ok(Url::parse("https://ny.storage.bunnycdn.com")?),
Endpoint::LosAngeles => Ok(Url::parse("https://la.storage.bunnycdn.com")?),
Endpoint::Singapore => Ok(Url::parse("https://sg.storage.bunnycdn.com")?),
Endpoint::Stockholm => Ok(Url::parse("https://se.storage.bunnycdn.com")?),
Endpoint::SaoPaulo => Ok(Url::parse("https://br.storage.bunnycdn.com")?),
Endpoint::Johannesburg => Ok(Url::parse("https://jh.storage.bunnycdn.com")?),
Endpoint::Sydney => Ok(Url::parse("https://syd.storage.bunnycdn.com")?),
Endpoint::Custom(url) => Ok(Url::parse(&url)?),
}
}
}