ninja_files_data2/filename/
mod.rs1use std::borrow::Cow;
2
3use camino::Utf8Path;
4
5#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
6pub struct FileName(Cow<'static, Utf8Path>);
7
8#[derive(Clone, Debug)]
9pub struct InvalidFileName(pub String);
10
11impl FileName {
12 pub fn try_create<S>(filename: S) -> Result<Self, InvalidFileName>
13 where
14 S: AsRef<Utf8Path>,
15 {
16 Ok(FileName(Cow::Owned(filename.as_ref().into())))
17 }
18}
19
20impl AsRef<str> for FileName {
21 fn as_ref(&self) -> &str {
22 self.0.as_ref().as_ref()
23 }
24}
25
26impl AsRef<Utf8Path> for FileName {
27 fn as_ref(&self) -> &Utf8Path {
28 self.0.as_ref()
29 }
30}