use int_enum::IntEnum;
use thiserror::Error;
#[repr(u32)]
#[derive(Debug, Error, IntEnum, PartialEq, Eq)]
pub enum ProtocolError {
#[error("Command not permitted (NBD_EPERM)")]
CommandNotPermitted = 1,
#[error("Input/output error (NBD_EIO)")]
IO = 5,
#[error("Cannot allocate memory (NBD_ENOMEM)")]
OutOfMemory = 12,
#[error("Invalid argument (NBD_EINVAL)")]
InvalidArgument = 22,
#[error("No space left on device (NBD_ENOSPC)")]
NoSpaceLeft = 28,
#[error("Value too large (NBD_EOVERFLOW)")]
ValueTooLarge = 75,
#[error("Command not supported (NBD_ENOTSUP)")]
CommandNotSupported = 95,
#[error("Server is in the process of being shut down (NBD_ESHUTDOWN)")]
ServerShuttingDown = 108,
}
#[repr(u32)]
#[derive(Debug, Error, IntEnum, PartialEq, Eq, Clone, Copy)]
pub enum OptionReplyError {
#[error("Unsupported option (NBD_REP_ERR_UNSUP)")]
Unsupported = 0x80000001,
#[error("Policy error (NBD_REP_ERR_POLICY)")]
Policy = 0x80000002,
#[error("Invalid option (NBD_REP_ERR_INVALID)")]
Invalid = 0x80000003,
#[error("Platform error (NBD_REP_ERR_PLATFORM)")]
Platform = 0x80000004,
#[error("TLS required (NBD_REP_ERR_TLS_REQD)")]
TLSRequired = 0x80000005,
#[error("Unknown export (NBD_REP_ERR_UNKNOWN)")]
UnknownExport = 0x80000006,
#[error("Server shutting down (NBD_REP_ERR_SHUTDOWN)")]
Shutdown = 0x80000007,
#[error("Block size required (NBD_REP_ERR_BLOCK_SIZE_REQD)")]
BlockSizeRequired = 0x80000008,
#[error("Request too big (NBD_REP_ERR_TOO_BIG)")]
TooBig = 0x80000009,
#[error("Extended header required (NBD_REP_ERR_EXT_HEADER_REQD)")]
ExtendedHeaderRequired = 0x8000000A,
}