virtio_drivers/device/socket/
error.rs1use core::result;
4use thiserror::Error;
5
6#[derive(Copy, Clone, Debug, Eq, Error, PartialEq)]
8pub enum SocketError {
9 #[error("There is an existing connection. Please close the current connection before attempting to connect again.")]
11 ConnectionExists,
12 #[error("The device is not connected to any peer. Please connect it to a peer first.")]
14 NotConnected,
15 #[error("The peer socket is shutdown.")]
17 PeerSocketShutdown,
18 #[error("The given buffer is shorter than expected")]
20 BufferTooShort,
21 #[error("The given output buffer is too short. '{0}' bytes is needed for the output buffer.")]
23 OutputBufferTooShort(usize),
24 #[error("The given buffer length '{0}' has exceeded the maximum allowed buffer length '{1}'")]
26 BufferTooLong(usize, usize),
27 #[error("The operation code '{0}' is unknown")]
29 UnknownOperation(u16),
30 #[error("Invalid operation")]
32 InvalidOperation,
33 #[error("Invalid number")]
35 InvalidNumber,
36 #[error("No data is expected in the packet")]
38 UnexpectedDataInPacket,
39 #[error("Peer has insufficient buffer space, try again later")]
41 InsufficientBufferSpaceInPeer,
42 #[error("Recycled a wrong buffer")]
44 RecycledWrongBuffer,
45}
46
47pub type Result<T> = result::Result<T, SocketError>;