hyprstream_containedfs/error.rs
1//! Filesystem error types.
2
3/// Filesystem containment error type.
4///
5/// Covers filesystem-level errors only. Protocol errors (`BadFd`, `Transport`,
6/// `Unavailable`) belong in the service layer (e.g., `RegistryService`).
7#[derive(Debug, thiserror::Error)]
8pub enum FsError {
9 /// Path or file not found.
10 #[error("Not found: {0}")]
11 NotFound(String),
12
13 /// Permission denied.
14 #[error("Permission denied: {0}")]
15 PermissionDenied(String),
16
17 /// Path escaped containment root (symlink or traversal attack).
18 #[error("Path containment violation: {0}")]
19 PathEscape(String),
20
21 /// Target already exists (e.g., `create` with `OEXCL`, `mkdir` on existing).
22 #[error("Already exists: {0}")]
23 AlreadyExists(String),
24
25 /// Underlying I/O error.
26 #[error("I/O error: {0}")]
27 Io(#[from] std::io::Error),
28
29 /// Resource limit exceeded.
30 #[error("Resource limit exceeded: {0}")]
31 ResourceLimit(String),
32}
33
34impl FsError {
35 /// Create a `PathEscape` error from a message.
36 pub fn path_escape(msg: impl Into<String>) -> Self {
37 Self::PathEscape(msg.into())
38 }
39
40 /// Create a `NotFound` error from a message.
41 pub fn not_found(msg: impl Into<String>) -> Self {
42 Self::NotFound(msg.into())
43 }
44}