pub struct Initializer { /* private fields */ }Expand description
LM sensors library initializer, producing an instance of LMSensors.
Implementations§
Source§impl Initializer
impl Initializer
Sourcepub fn config_path(self, path: impl Into<PathBuf>) -> Self
pub fn config_path(self, path: impl Into<PathBuf>) -> Self
Set the path of the configuration file to be read during LM sensors library initialization.
§Example
let sensors = lm_sensors::Initializer::default()
.config_path("/dev/null")
.initialize()?;Sourcepub fn config_file(self, file: File) -> Self
pub fn config_file(self, file: File) -> Self
Set the configuration contents to be used during LM sensors library initialization.
§Example
let config_file = File::open("/dev/null").unwrap();
let sensors = lm_sensors::Initializer::default()
.config_file(config_file)
.initialize()?;Sourcepub fn error_listener(self, listener: Box<dyn Listener>) -> Self
pub fn error_listener(self, listener: Box<dyn Listener>) -> Self
Set the error listener to be used during LM sensors library initialization.
§Example
#[derive(Debug)]
struct EL;
impl lm_sensors::errors::Listener for EL {
fn on_lm_sensors_config_error(&self, error: &str,
file_name: Option<&std::path::Path>, line_number: usize)
{
if let Some(file_name) = file_name {
eprintln!("[ERROR] lm-sensors config: {} @{}:{}",
error, file_name.display(), line_number);
} else {
eprintln!("[ERROR] lm-sensors config: {} @<config>:{}",
error, line_number);
}
}
fn on_lm_sensors_fatal_error(&self, error: &str, procedure: &str) {
eprintln!("[FATAL] lm-sensors: {} @{}", error, procedure);
}
}
let sensors = lm_sensors::Initializer::default()
.error_listener(Box::new(EL))
.initialize()?;Sourcepub fn initialize(self) -> Result<LMSensors>
pub fn initialize(self) -> Result<LMSensors>
Return an instance of a loaded and initialized LM sensors library.
§Example
let sensors = lm_sensors::Initializer::default().initialize()?;Trait Implementations§
Source§impl Debug for Initializer
impl Debug for Initializer
Source§impl Default for Initializer
impl Default for Initializer
Source§fn default() -> Initializer
fn default() -> Initializer
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for Initializer
impl !RefUnwindSafe for Initializer
impl !Send for Initializer
impl !Sync for Initializer
impl Unpin for Initializer
impl !UnwindSafe for Initializer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more