use std::{error::Error, fmt};
pub type PortResult<T> = Result<T, HostDirError>;
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum HostDirErrorKind {
NotFound,
AlreadyExists,
Escape,
SpecialFile,
Malformed,
QuotaExceeded,
Cancelled,
NotEmpty,
Native,
Unsupported,
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct HostDirError {
pub kind: HostDirErrorKind,
pub message: String,
}
impl HostDirError {
pub fn new(kind: HostDirErrorKind, message: impl Into<String>) -> Self {
Self {
kind,
message: message.into(),
}
}
}
impl fmt::Display for HostDirError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(&self.message)
}
}
impl Error for HostDirError {}