Skip to content

Commit

Permalink
fmt clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
staszek-krotki committed Mar 29, 2024
1 parent fd182d8 commit 7513a0d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
10 changes: 5 additions & 5 deletions gpu-detection/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use anyhow::{bail, Context};
use model::{Clocks, Cuda, Gpu, Memory};
use nvml_wrapper::{enum_wrappers::device::Clock, Device, Nvml};
use nvml_wrapper::error::NvmlError;
use nvml_wrapper::{enum_wrappers::device::Clock, Device, Nvml};
use thiserror::Error;

pub mod model;
Expand All @@ -11,7 +11,7 @@ pub enum GpuDetectionError {
#[error("a libloading error occurred: {0}")]
LibloadingError(#[from] libloading::Error),
#[error("an unknown error occurred: {0}")]
Unknown(String)
Unknown(String),
}

pub struct GpuDetection {
Expand All @@ -24,11 +24,11 @@ impl GpuDetection {
Ok(nvlm) => nvlm,
Err(NvmlError::LibloadingError(e)) => {
log::error!("GpuDetection library loading failed: {}", e);
return Err(GpuDetectionError::LibloadingError(e))
},
return Err(GpuDetectionError::LibloadingError(e));
}
Err(e) => {
log::error!("GpuDetection init failed: {}", e);
return Err(GpuDetectionError::Unknown(e.to_string()))
return Err(GpuDetectionError::Unknown(e.to_string()));
}
};
Ok(Self { nvml })
Expand Down
10 changes: 4 additions & 6 deletions src/offer_template.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::process::RuntimeConfig;
use gpu_detection::model::Gpu;

use gpu_detection::GpuDetectionError;
use serde::{Deserialize, Serialize};
use std::borrow::Cow;
use std::collections::BTreeMap;
use gpu_detection::GpuDetectionError;

#[derive(Deserialize, Serialize)]
struct OfferTemplate {
Expand All @@ -15,12 +15,10 @@ pub(crate) fn gpu_detection<CONFIG: RuntimeConfig>(config: &CONFIG) -> anyhow::R
match gpu_detection::GpuDetection::init() {
Ok(gpu_detection) => {
let gpu = gpu_detection.detect(config.gpu_uuid())?;
return Ok(Some(gpu));
Ok(Some(gpu))
}
Err(GpuDetectionError::LibloadingError(_)) => {
return Ok(None);
},
Err(e) => Err(e.into())
Err(GpuDetectionError::LibloadingError(_)) => Ok(None),
Err(e) => Err(e.into()),
}
}

Expand Down

0 comments on commit 7513a0d

Please sign in to comment.