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(
11 "There is an existing connection. Please close the current connection before attempting to connect again."
12 )]
13 ConnectionExists,
14 #[error("The device is not connected to any peer. Please connect it to a peer first.")]
16 NotConnected,
17 #[error("The peer socket is shutdown.")]
19 PeerSocketShutdown,
20 #[error("The given buffer is shorter than expected")]
22 BufferTooShort,
23 #[error("The given output buffer is too short. '{0}' bytes is needed for the output buffer.")]
25 OutputBufferTooShort(usize),
26 #[error("The given buffer length '{0}' has exceeded the maximum allowed buffer length '{1}'")]
28 BufferTooLong(usize, usize),
29 #[error("The operation code '{0}' is unknown")]
31 UnknownOperation(u16),
32 #[error("Invalid operation")]
34 InvalidOperation,
35 #[error("Invalid number")]
37 InvalidNumber,
38 #[error("No data is expected in the packet")]
40 UnexpectedDataInPacket,
41 #[error("Peer has insufficient buffer space, try again later")]
43 InsufficientBufferSpaceInPeer,
44 #[error("Recycled a wrong buffer")]
46 RecycledWrongBuffer,
47}
48
49pub type Result<T> = result::Result<T, SocketError>;