introduce TaskState trait
Used to not require access to the WorkerTask struct outside the `server` and `api2` module, so it'll be easier to separate those backup/server/client parts into separate crates. Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
@ -851,3 +851,19 @@ impl WorkerTask {
|
||||
&self.upid
|
||||
}
|
||||
}
|
||||
|
||||
impl crate::task::TaskState for WorkerTask {
|
||||
fn check_abort(&self) -> Result<(), Error> {
|
||||
self.fail_on_abort()
|
||||
}
|
||||
|
||||
fn log(&self, level: log::Level, message: &std::fmt::Arguments) {
|
||||
match level {
|
||||
log::Level::Error => self.warn(&message.to_string()),
|
||||
log::Level::Warn => self.warn(&message.to_string()),
|
||||
log::Level::Info => self.log(&message.to_string()),
|
||||
log::Level::Debug => self.log(&format!("DEBUG: {}", message)),
|
||||
log::Level::Trace => self.log(&format!("TRACE: {}", message)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user