mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-31 08:28:34 +00:00
runtime-rs: Remove direct implementation of ToString
Fix clippy error: ``` direct implementation of `ToString` ``` by switching to implement Display instead Signed-off-by: stevenhorsman <steven@uk.ibm.com>
This commit is contained in:
@@ -560,11 +560,8 @@ impl PCIeDevice for VfioDevice {
|
||||
))?;
|
||||
hostdev.guest_pci_path = Some(pci_path.clone());
|
||||
|
||||
self.device_options.push(format!(
|
||||
"0000:{}={}",
|
||||
hostdev.bus_slot_func,
|
||||
pci_path.to_string()
|
||||
));
|
||||
self.device_options
|
||||
.push(format!("0000:{}={}", hostdev.bus_slot_func, pci_path));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
@@ -33,9 +33,9 @@ impl PciSlot {
|
||||
}
|
||||
}
|
||||
|
||||
impl ToString for PciSlot {
|
||||
fn to_string(&self) -> String {
|
||||
format!("{:02x}", self.0)
|
||||
impl std::fmt::Display for PciSlot {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "{:02x}", self.0)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,14 +116,17 @@ impl PciPath {
|
||||
}
|
||||
}
|
||||
|
||||
impl ToString for PciPath {
|
||||
// method to format the PciPath into a string
|
||||
fn to_string(&self) -> String {
|
||||
self.slots
|
||||
.iter()
|
||||
.map(|pci_slot| format!("{:02x}", pci_slot.0))
|
||||
.collect::<Vec<String>>()
|
||||
.join("/")
|
||||
impl std::fmt::Display for PciPath {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"{}",
|
||||
self.slots
|
||||
.iter()
|
||||
.map(|pci_slot| format!("{:02x}", pci_slot.0))
|
||||
.collect::<Vec<String>>()
|
||||
.join("/")
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1540,13 +1540,14 @@ impl MonitorProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
impl ToString for MonitorProtocol {
|
||||
fn to_string(&self) -> String {
|
||||
match *self {
|
||||
impl std::fmt::Display for MonitorProtocol {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
let to_string = match *self {
|
||||
MonitorProtocol::Hmp => "monitor".to_string(),
|
||||
MonitorProtocol::QmpPretty => "qmp-pretty".to_string(),
|
||||
_ => "qmp".to_string(),
|
||||
}
|
||||
};
|
||||
write!(f, "{}", to_string)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1604,7 +1605,7 @@ impl QmpSocket {
|
||||
#[async_trait]
|
||||
impl ToQemuParams for QmpSocket {
|
||||
async fn qemu_params(&self) -> Result<Vec<String>> {
|
||||
let param_qmp = format!("-{}", self.protocol.to_string());
|
||||
let param_qmp = format!("-{}", self.protocol);
|
||||
|
||||
let mut params: Vec<String> = Vec::new();
|
||||
|
||||
|
@@ -78,9 +78,9 @@ pub struct ContainerID {
|
||||
pub container_id: String,
|
||||
}
|
||||
|
||||
impl ToString for ContainerID {
|
||||
fn to_string(&self) -> String {
|
||||
self.container_id.clone()
|
||||
impl std::fmt::Display for ContainerID {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "{}", self.container_id)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user