corevm-host 0.1.28

Types that are common across CoreVM service, builder, monitor, tooling
Documentation
/// Generic file system error.
#[derive(Debug)]
pub enum Error {
	/// Invalid file block.
	Block,
	/// Input/output error.
	Io,
	/// Invalid node kind.
	Node,
	/// Path resolution error.
	Path,
	/// File system loop.
	Loop,
}

impl core::fmt::Display for Error {
	fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
		core::fmt::Debug::fmt(self, f)
	}
}

#[cfg(any(feature = "std", test))]
impl std::error::Error for Error {}

impl From<InvalidBlock> for Error {
	fn from(_: InvalidBlock) -> Self {
		Self::Block
	}
}

impl From<IoError> for Error {
	fn from(_: IoError) -> Self {
		Self::Io
	}
}

/// Invalid file block.
#[derive(Debug)]
pub struct InvalidBlock;

impl core::fmt::Display for InvalidBlock {
	fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
		core::fmt::Debug::fmt(self, f)
	}
}

#[cfg(any(feature = "std", test))]
impl std::error::Error for InvalidBlock {}

/// Path resolution error.
#[derive(Debug)]
pub struct InvalidPath;

impl core::fmt::Display for InvalidPath {
	fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
		core::fmt::Debug::fmt(self, f)
	}
}

#[cfg(any(feature = "std", test))]
impl std::error::Error for InvalidPath {}

/// Input/output error.
#[derive(Debug)]
pub struct IoError;

impl core::fmt::Display for IoError {
	fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
		core::fmt::Debug::fmt(self, f)
	}
}

#[cfg(any(feature = "std", test))]
impl std::error::Error for IoError {}