use alloc::format; use alloc::string::String; use core::fmt::Debug; /// An enum for all errors that may occur #[derive(Clone, PartialEq, Debug)] pub enum IFError { /// An error that was created in some dependency and then converted to `IFError` General(String), /// A tunnel satisfying some conditions has not been found TunnelNotFound, /// Could not establish a connection CouldNotConnect, /// Error during serialization SerializationError(String), /// Error in rsa CryptoError(String), /// Error in std::io IoError(String), } // impl From for IFError { // /// Convert from other error // fn from(e: T) -> Self { // Self::General(format!("{:?}", e)) // } // } #[cfg(feature = "std")] impl From for IFError { fn from(e: std::io::Error) -> Self { Self::IoError(format!("{:?}", e)) } } impl From for IFError { fn from(e: serde_cbor::Error) -> Self { Self::SerializationError(format!("{:?}", e)) } } impl From for IFError { fn from(e: rsa::errors::Error) -> Self { Self::CryptoError(format!("{:?}", e)) } } pub type IFResult = Result;