From fd81a23fccf8b6dd75c72c331f9e08838611fde9 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Sun, 24 Mar 2024 18:13:41 +0000 Subject: [PATCH] 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 --- virtio-devices/src/vsock/csm/mod.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/virtio-devices/src/vsock/csm/mod.rs b/virtio-devices/src/vsock/csm/mod.rs index beb2e9bda..01c8aac84 100644 --- a/virtio-devices/src/vsock/csm/mod.rs +++ b/virtio-devices/src/vsock/csm/mod.rs @@ -4,6 +4,8 @@ //! 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. +use thiserror::Error; + mod connection; mod txbuf; @@ -24,13 +26,16 @@ pub mod defs { pub const CONN_SHUTDOWN_TIMEOUT_MS: u64 = 2000; } -#[derive(Debug)] +#[derive(Debug, Error)] pub enum Error { /// Attempted to push data to a full TX buffer. + #[error("TX buffer full")] TxBufFull, /// An I/O error occurred, when attempting to flush the connection TX buffer. + #[error("Error flushing TX buffer: {0}")] TxBufFlush(std::io::Error), /// 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), }