use std::str::FromStr;
use super::SubscriptionTopic;
#[derive(Clone, Debug)]
pub struct SubscriptionName(String);
impl SubscriptionName {
pub fn new(name: impl AsRef<str>) -> Self {
Self(name.as_ref().to_owned())
}
pub fn parse_string(candiate: impl AsRef<str>) -> Result<Self, String> {
Ok(Self::new(candiate))
}
}
impl SubscriptionTopic for SubscriptionName {
fn stream_name(&self) -> SubscriptionName {
self.clone()
}
}
impl std::fmt::Display for SubscriptionName {
fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(formatter, "{}", self.0)
}
}
impl AsRef<str> for SubscriptionName {
fn as_ref(&self) -> &str {
&self.0
}
}
impl FromStr for SubscriptionName {
type Err = String;
fn from_str(candidate: &str) -> Result<Self, Self::Err> {
Self::parse_string(candidate)
}
}