sp_wasm_memfs/
error.rs

1use std::io;
2
3#[derive(Debug, thiserror::Error)]
4pub enum Error {
5    #[error("file '{0}' already exists")]
6    AlreadyExists(String),
7    #[error("file '{0}' not found")]
8    NotFound(String),
9    #[error("invalid path: '{0}'")]
10    InvalidPath(String),
11    #[error("file is root")]
12    IsRoot,
13    #[error("{0}")]
14    Io(#[from] io::Error),
15}
16
17impl PartialEq for Error {
18    fn eq(&self, other: &Error) -> bool {
19        match (self, other) {
20            (&Error::AlreadyExists(ref left), &Error::AlreadyExists(ref right)) => left == right,
21            (&Error::NotFound(ref left), &Error::NotFound(ref right)) => left == right,
22            (&Error::InvalidPath(ref left), &Error::InvalidPath(ref right)) => left == right,
23            (&Error::IsRoot, &Error::IsRoot) => true,
24            (&Error::Io(ref left), &Error::Io(ref right)) => left.kind() == right.kind(),
25            (_, _) => false,
26        }
27    }
28}