fix: removed unimplemnted marco and returned Err instead
Some checks are pending
Run Check Script / check (pull_request) Waiting to run
Some checks are pending
Run Check Script / check (pull_request) Waiting to run
some formatting error
This commit is contained in:
parent
8126b233d8
commit
5af13800b7
@ -20,21 +20,20 @@ impl<'a> NodeExporterConfig<'a> {
|
||||
pub fn get_full_config(&self) -> &Option<NodeExporter> {
|
||||
&self.opnsense.opnsense.node_exporter
|
||||
}
|
||||
fn with_node_exporter<F, R>(&mut self, f: F) -> R
|
||||
|
||||
fn with_node_exporter<F, R>(&mut self, f: F) -> Result<R, &'static str>
|
||||
where
|
||||
F: FnOnce(&mut NodeExporter) -> R,
|
||||
{
|
||||
match &mut self.opnsense.opnsense.node_exporter.as_mut() {
|
||||
Some(node_exporter) => f(node_exporter),
|
||||
None => unimplemented!(
|
||||
"
|
||||
node exporter is not yet installed"
|
||||
),
|
||||
Some(node_exporter) => Ok(f(node_exporter)),
|
||||
None => Err("node exporter is not yet installed"),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn enable(&mut self, enabled: bool) {
|
||||
pub fn enable(&mut self, enabled: bool) -> Result<(), &'static str> {
|
||||
self.with_node_exporter(|node_exporter| node_exporter.enabled = enabled as u8)
|
||||
.map(|_| ())
|
||||
}
|
||||
|
||||
pub async fn reload_restart(&self) -> Result<(), Error> {
|
||||
|
Loading…
Reference in New Issue
Block a user