virtio_drivers/device/socket/
error.rsuse core::result;
use thiserror::Error;
#[derive(Copy, Clone, Debug, Eq, Error, PartialEq)]
pub enum SocketError {
#[error("There is an existing connection. Please close the current connection before attempting to connect again.")]
ConnectionExists,
#[error("The device is not connected to any peer. Please connect it to a peer first.")]
NotConnected,
#[error("The peer socket is shutdown.")]
PeerSocketShutdown,
#[error("The given buffer is shorter than expected")]
BufferTooShort,
#[error("The given output buffer is too short. '{0}' bytes is needed for the output buffer.")]
OutputBufferTooShort(usize),
#[error("The given buffer length '{0}' has exceeded the maximum allowed buffer length '{1}'")]
BufferTooLong(usize, usize),
#[error("The operation code '{0}' is unknown")]
UnknownOperation(u16),
#[error("Invalid operation")]
InvalidOperation,
#[error("Invalid number")]
InvalidNumber,
#[error("No data is expected in the packet")]
UnexpectedDataInPacket,
#[error("Peer has insufficient buffer space, try again later")]
InsufficientBufferSpaceInPeer,
#[error("Recycled a wrong buffer")]
RecycledWrongBuffer,
}
pub type Result<T> = result::Result<T, SocketError>;