use std::borrow::Cow;
use camino::Utf8Path;
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct FileName(Cow<'static, Utf8Path>);
#[derive(Clone, Debug)]
pub struct InvalidFileName(pub String);
impl FileName {
pub fn try_create<S>(filename: S) -> Result<Self, InvalidFileName>
where
S: AsRef<Utf8Path>,
{
Ok(FileName(Cow::Owned(filename.as_ref().into())))
}
}
impl AsRef<str> for FileName {
fn as_ref(&self) -> &str {
self.0.as_ref().as_ref()
}
}
impl AsRef<Utf8Path> for FileName {
fn as_ref(&self) -> &Utf8Path {
self.0.as_ref()
}
}