pub mod backend;
pub mod bindings;
pub mod conn;
pub mod frontend;
use std::path::Path;
use snafu::Snafu;
use crate::errors::{DebugTrace, trace_error};
use crate::virtio::vu::bindings::VuFeature;
#[trace_error]
#[derive(Snafu, DebugTrace)]
#[snafu(module, visibility(pub(crate)), context(suffix(false)))]
pub enum Error {
#[snafu(display("Cannot access socket {path:?}"))]
AccessSocket {
path: Box<Path>,
error: std::io::Error,
},
#[snafu(display("Error from OS"), context(false))]
System { error: std::io::Error },
#[snafu(display("vhost-user message ({req:#x}) missing fd"))]
MissingFd { req: u32 },
#[snafu(display("Unexpected vhost-user response, want {want}, got {got}"))]
Response { want: u32, got: u32 },
#[snafu(display("Unexpected vhost-user message size, want {want}, get {got}"))]
MsgSize { want: usize, got: usize },
#[snafu(display("Failed to send {want} bytes, only {done} bytes were sent"))]
PartialWrite { want: usize, done: usize },
#[snafu(display("Invalid vhost-user message payload size, want {want}, got {got}"))]
PayloadSize { want: usize, got: u32 },
#[snafu(display("vhost-user backend replied error code {ret:#x} to request {req:#x}"))]
RequestErr { ret: u64, req: u32 },
#[snafu(display("vhost-user backend signaled an error of queue {index:#x}"))]
QueueErr { index: u16 },
#[snafu(display("vhost-user backend is missing device feature {feature:#x}"))]
DeviceFeature { feature: u128 },
#[snafu(display("vhost-user backend is missing protocol feature {feature:x?}"))]
ProtocolFeature { feature: VuFeature },
}
type Result<T, E = Error> = std::result::Result<T, E>;