mirror of
https://github.com/rust-vmm/vhost-device.git
synced 2025-12-25 22:18:59 +00:00
scsi: remove num_enum dependency
num_enum is only used to derive TryFrom<u8> for two types, while TryFrom<u8> is implemented manually for other enums. Remove it since it's not necessary. Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
This commit is contained in:
parent
dff8efdd2b
commit
893ae1d83d
23
Cargo.lock
generated
23
Cargo.lock
generated
@ -1204,28 +1204,6 @@ dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num_enum"
|
||||
version = "0.7.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b1207a7e20ad57b847bbddc6776b968420d38292bbfe2089accff5e19e82454c"
|
||||
dependencies = [
|
||||
"num_enum_derive",
|
||||
"rustversion",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num_enum_derive"
|
||||
version = "0.7.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ff32365de1b6743cb203b710788263c44a03de03802daf96092f2da4fe6ba4d7"
|
||||
dependencies = [
|
||||
"proc-macro-crate",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.106",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.21.3"
|
||||
@ -2199,7 +2177,6 @@ dependencies = [
|
||||
"env_logger",
|
||||
"epoll",
|
||||
"log",
|
||||
"num_enum",
|
||||
"tempfile",
|
||||
"thiserror 2.0.17",
|
||||
"vhost",
|
||||
|
||||
@ -19,7 +19,6 @@ clap = { version = "4.5", features = ["derive"] }
|
||||
env_logger = "0.11"
|
||||
epoll = "4.4"
|
||||
log = "0.4"
|
||||
num_enum = "0.7"
|
||||
thiserror = "2.0"
|
||||
vhost = { version = "0.14", features = ["vhost-user-backend"] }
|
||||
vhost-user-backend = "0.20"
|
||||
|
||||
@ -13,12 +13,11 @@
|
||||
use std::convert::{TryFrom, TryInto};
|
||||
|
||||
use log::warn;
|
||||
use num_enum::TryFromPrimitive;
|
||||
|
||||
use crate::scsi::emulation::mode_page::ModePage;
|
||||
|
||||
/// One of the modes supported by SCSI's REPORT LUNS command.
|
||||
#[derive(PartialEq, Eq, TryFromPrimitive, Debug, Copy, Clone)]
|
||||
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
|
||||
#[repr(u8)]
|
||||
pub(crate) enum ReportLunsSelectReport {
|
||||
NoWellKnown = 0x0,
|
||||
@ -29,6 +28,22 @@ pub(crate) enum ReportLunsSelectReport {
|
||||
SameConglomerate = 0x12,
|
||||
}
|
||||
|
||||
impl TryFrom<u8> for ReportLunsSelectReport {
|
||||
type Error = ();
|
||||
|
||||
fn try_from(val: u8) -> Result<Self, ()> {
|
||||
match val {
|
||||
0x0 => Ok(Self::NoWellKnown),
|
||||
0x1 => Ok(Self::WellKnownOnly),
|
||||
0x2 => Ok(Self::All),
|
||||
0x10 => Ok(Self::Administrative),
|
||||
0x11 => Ok(Self::TopLevel),
|
||||
0x12 => Ok(Self::SameConglomerate),
|
||||
_ => Err(()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A type of "vital product data" page returned by SCSI's INQUIRY command.
|
||||
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
|
||||
pub(crate) enum VpdPage {
|
||||
@ -61,7 +76,7 @@ pub(crate) enum VpdPage {
|
||||
}
|
||||
// starred ones are ones Linux will use if available
|
||||
|
||||
#[derive(PartialEq, Eq, TryFromPrimitive, Debug, Copy, Clone)]
|
||||
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
|
||||
#[repr(u8)]
|
||||
pub(crate) enum ModeSensePageControl {
|
||||
Current = 0b00,
|
||||
@ -70,6 +85,20 @@ pub(crate) enum ModeSensePageControl {
|
||||
Saved = 0b11,
|
||||
}
|
||||
|
||||
impl TryFrom<u8> for ModeSensePageControl {
|
||||
type Error = ();
|
||||
|
||||
fn try_from(val: u8) -> Result<Self, ()> {
|
||||
match val {
|
||||
0b00 => Ok(Self::Current),
|
||||
0b01 => Ok(Self::Changeable),
|
||||
0b10 => Ok(Self::Default),
|
||||
0b11 => Ok(Self::Saved),
|
||||
_ => Err(()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<u8> for VpdPage {
|
||||
type Error = ();
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user