1use std::{path::PathBuf, str::Chars};
2
3use crate::{inner::PathInner, iter::Segments};
4
5pub struct AnyPath(PathInner);
6
7impl AnyPath {
8 pub fn segments(&self) -> Segments {
9 self.0.segments()
10 }
11
12 pub fn chars(&self) -> Chars {
13 self.0.chars()
14 }
15}
16
17impl TryFrom<String> for AnyPath {
18 type Error = anyhow::Error;
19 fn try_from(value: String) -> Result<Self, Self::Error> {
20 Ok(Self(PathInner::new(&value)?))
21 }
22}
23
24impl TryFrom<&str> for AnyPath {
25 type Error = anyhow::Error;
26 fn try_from(value: &str) -> Result<Self, Self::Error> {
27 Ok(Self(PathInner::new(value)?))
28 }
29}
30
31impl TryFrom<PathBuf> for AnyPath {
32 type Error = anyhow::Error;
33
34 fn try_from(value: PathBuf) -> Result<Self, Self::Error> {
35 Ok(Self(PathInner::new_from_path(&value)?))
36 }
37}