harmos_runtime/filesystem/
error.rs1use std::{io, path::PathBuf};
18pub type Result<T, E = Error> = std::result::Result<T, E>;
29
30#[derive(Debug, thiserror::Error)]
35pub enum Error {
36 #[error("cannot {operation} {path}: {source}")]
37 Publication {
38 operation: &'static str,
39 path: PathBuf,
40
41 #[source]
42 source: io::Error,
43 },
44}
45
46impl Error {
51 pub(crate) fn publication(operation: &'static str, path: &std::path::Path, source: io::Error) -> Self {
52 Self::Publication { operation, path: path.to_owned(), source }
53 }
54
55 pub fn kind(&self) -> io::ErrorKind {
56 let Self::Publication { source, .. } = self;
57 source.kind()
58 }
59}
60
61impl From<Error> for io::Error {
62 fn from(error: Error) -> Self {
63 let Error::Publication { source, .. } = error;
64 source
65 }
66}
67
68