virtio-devices: vsock: csm: Use thiserror to provide error messages

This resolves a nightly compiler check for unused enum inner value.

Signed-off-by: Rob Bradford <rbradford@rivosinc.com>
This commit is contained in:
Rob Bradford 2024-03-24 18:13:41 +00:00 committed by Liu Wei
parent acc25def7d
commit fd81a23fcc

View File

@ -4,6 +4,8 @@
//! This module implements our vsock connection state machine. The heavy lifting is done by //! This module implements our vsock connection state machine. The heavy lifting is done by
//! `connection::VsockConnection`, while this file only defines some constants and helper structs. //! `connection::VsockConnection`, while this file only defines some constants and helper structs.
use thiserror::Error;
mod connection; mod connection;
mod txbuf; mod txbuf;
@ -24,13 +26,16 @@ pub mod defs {
pub const CONN_SHUTDOWN_TIMEOUT_MS: u64 = 2000; pub const CONN_SHUTDOWN_TIMEOUT_MS: u64 = 2000;
} }
#[derive(Debug)] #[derive(Debug, Error)]
pub enum Error { pub enum Error {
/// Attempted to push data to a full TX buffer. /// Attempted to push data to a full TX buffer.
#[error("TX buffer full")]
TxBufFull, TxBufFull,
/// An I/O error occurred, when attempting to flush the connection TX buffer. /// An I/O error occurred, when attempting to flush the connection TX buffer.
#[error("Error flushing TX buffer: {0}")]
TxBufFlush(std::io::Error), TxBufFlush(std::io::Error),
/// An I/O error occurred, when attempting to write data to the host-side stream. /// An I/O error occurred, when attempting to write data to the host-side stream.
#[error("Error writing to host side stream: {0}")]
StreamWrite(std::io::Error), StreamWrite(std::io::Error),
} }