typed_path/common/
errors.rs1use core::fmt;
2
3#[derive(Clone, Debug, PartialEq, Eq)]
11pub struct StripPrefixError(pub(crate) ());
12
13impl fmt::Display for StripPrefixError {
14 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
15 write!(f, "prefix not found")
16 }
17}
18
19#[cfg(feature = "std")]
20impl std::error::Error for StripPrefixError {}
21
22#[derive(Clone, Debug, PartialEq, Eq)]
24pub enum CheckedPathError {
25 InvalidFilename,
27
28 PathTraversalAttack,
31
32 UnexpectedPrefix,
34
35 UnexpectedRoot,
37}
38
39impl fmt::Display for CheckedPathError {
40 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
41 match self {
42 Self::InvalidFilename => write!(f, "path contains invalid filename"),
43 Self::PathTraversalAttack => write!(f, "path attempts to escape original path"),
44 Self::UnexpectedPrefix => write!(f, "path contains unexpected prefix"),
45 Self::UnexpectedRoot => write!(f, "path contains unexpected root"),
46 }
47 }
48}
49
50#[cfg(feature = "std")]
51impl std::error::Error for CheckedPathError {}